home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / RLaB 1.18c / manual / userfunc.tex < prev    next >
LaTeX Document  |  1994-04-29  |  18.1 KB  |  [TEXT/ttxt]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: userfunc.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[ttxt]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 63 68 61 70 74 65 72 | 7b 55 73 65 72 2d 64 65 |\chapter|{User-de|
|00000010| 66 69 6e 65 64 20 46 75 | 6e 63 74 69 6f 6e 73 7d |fined Fu|nctions}|
|00000020| 0d 0d 0d 20 20 20 49 74 | 20 69 73 20 61 73 73 75 |... It| is assu|
|00000030| 6d 65 64 20 74 68 61 74 | 20 74 68 65 20 72 65 61 |med that| the rea|
|00000040| 64 65 72 20 68 61 73 20 | 68 61 64 20 73 6f 6d 65 |der has |had some|
|00000050| 20 70 72 6f 67 72 61 6d | 6d 69 6e 67 20 65 78 70 | program|ming exp|
|00000060| 65 72 69 65 6e 63 65 0d | 20 20 20 77 69 74 68 20 |erience.| with |
|00000070| 61 20 68 69 67 68 2d 6c | 65 76 65 6c 20 6c 61 6e |a high-l|evel lan|
|00000080| 67 75 61 67 65 20 6c 69 | 6b 65 20 46 6f 72 74 72 |guage li|ke Fortr|
|00000090| 61 6e 2c 20 6f 72 20 65 | 76 65 6e 20 62 65 74 74 |an, or e|ven bett|
|000000a0| 65 72 2c 20 61 0d 20 20 | 20 6c 6f 77 65 72 2d 6c |er, a. | lower-l|
|000000b0| 65 76 65 6c 20 6c 61 6e | 67 75 61 67 65 20 6c 69 |evel lan|guage li|
|000000c0| 6b 65 20 43 2e 20 0d 0d | 5c 73 65 63 74 69 6f 6e |ke C. ..|\section|
|000000d0| 7b 46 75 6e 63 74 69 6f | 6e 73 7d 0d 0d 59 6f 75 |{Functio|ns}..You|
|000000e0| 20 68 61 76 65 20 61 6c | 72 65 61 64 79 20 73 65 | have al|ready se|
|000000f0| 65 6e 20 73 6f 6d 65 20 | 6f 66 20 74 68 65 20 66 |en some |of the f|
|00000100| 75 6e 63 74 69 6f 6e 73 | 20 69 6e 20 75 73 65 2e |unctions| in use.|
|00000110| 20 20 54 68 65 72 65 20 | 61 72 65 20 66 6f 72 0d | There |are for.|
|00000120| 62 61 73 69 63 20 74 79 | 70 65 73 20 6f 66 20 66 |basic ty|pes of f|
|00000130| 75 6e 63 74 69 6f 6e 73 | 20 74 68 61 74 20 63 61 |unctions| that ca|
|00000140| 6e 20 6f 70 65 72 61 74 | 65 20 6f 6e 20 6d 61 74 |n operat|e on mat|
|00000150| 72 69 63 69 65 73 20 69 | 6e 20 5c 52 4c 61 42 5c |ricies i|n \RLaB\|
|00000160| 2e 20 54 68 65 79 0d 61 | 72 65 3a 20 0d 20 20 20 |. They.a|re: . |
|00000170| 5c 62 65 67 69 6e 7b 64 | 65 73 63 72 69 70 74 69 |\begin{d|escripti|
|00000180| 6f 6e 7d 0d 0d 20 20 20 | 20 20 5c 69 74 65 6d 5b |on}.. | \item[|
|00000190| 53 63 61 6c 61 72 20 46 | 75 6e 63 74 69 6f 6e 73 |Scalar F|unctions|
|000001a0| 3a 5d 20 54 68 65 73 65 | 20 66 75 6e 63 74 69 6f |:] These| functio|
|000001b0| 6e 73 20 6f 70 65 72 61 | 74 65 20 6f 6e 20 73 63 |ns opera|te on sc|
|000001c0| 61 6c 61 72 73 2c 20 61 | 6e 64 0d 20 20 20 20 20 |alars, a|nd. |
|000001d0| 20 20 20 20 20 20 74 72 | 65 61 74 20 6d 61 74 72 | tr|eat matr|
|000001e0| 69 63 65 73 20 69 6e 20 | 61 6e 20 65 6c 65 6d 65 |ices in |an eleme|
|000001f0| 6e 74 2d 62 79 2d 65 6c | 65 6d 65 6e 74 20 66 61 |nt-by-el|ement fa|
|00000200| 73 68 69 6f 6e 2e 20 53 | 6f 6d 65 0d 20 20 20 20 |shion. S|ome. |
|00000210| 20 20 20 20 20 20 20 65 | 78 61 6d 70 6c 65 73 20 | e|xamples |
|00000220| 61 72 65 3a 0d 0d 20 20 | 20 20 20 20 20 20 20 20 |are:.. | |
|00000230| 20 5c 62 65 67 69 6e 7b | 74 61 62 62 69 6e 67 7d | \begin{|tabbing}|
|00000240| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 20 66 75 |. | fu|
|00000250| 6e 63 74 69 6f 6e 31 20 | 5c 3d 20 66 75 6e 63 74 |nction1 |\= funct|
|00000260| 69 6f 6e 32 20 5c 3d 20 | 66 75 6e 63 74 69 6f 6e |ion2 \= |function|
|00000270| 32 20 5c 3d 20 66 75 6e | 63 74 69 6f 6e 34 20 5c |2 \= fun|ction4 \|
|00000280| 6b 69 6c 6c 20 20 20 20 | 20 20 20 20 0d 20 20 20 |kill | . |
|00000290| 20 20 20 20 20 20 20 20 | 20 20 61 62 73 20 5c 3e | | abs \>|
|000002a0| 20 65 78 70 20 5c 3e 20 | 66 6c 6f 6f 72 20 5c 3e | exp \> |floor \>|
|000002b0| 20 72 6f 75 6e 64 20 5c | 5c 0d 20 20 20 20 20 20 | round \|\. |
|000002c0| 20 20 20 20 20 20 20 63 | 6f 73 20 5c 3e 20 73 69 | c|os \> si|
|000002d0| 6e 20 5c 3e 20 74 61 6e | 20 5c 3e 20 63 65 69 6c |n \> tan| \> ceil|
|000002e0| 20 5c 5c 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 | \\. | |
|000002f0| 20 73 71 72 74 20 5c 3e | 20 72 65 61 6c 20 5c 3e | sqrt \>| real \>|
|00000300| 20 69 6d 61 67 20 5c 3e | 20 63 6f 6e 6a 20 5c 5c | imag \>| conj \\|
|00000310| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 20 69 73 |. | is|
|00000320| 6e 61 6e 20 5c 3e 20 69 | 6e 74 20 5c 3e 20 5c 3e |nan \> i|nt \> \>|
|00000330| 20 5c 5c 0d 20 20 20 20 | 20 20 20 20 20 20 20 5c | \\. | \|
|00000340| 65 6e 64 7b 74 61 62 62 | 69 6e 67 7d 0d 0d 20 20 |end{tabb|ing}.. |
|00000350| 20 20 20 5c 69 74 65 6d | 5b 56 65 63 74 6f 72 20 | \item|[Vector |
|00000360| 46 75 6e 63 74 69 6f 6e | 73 3a 5d 20 54 68 65 73 |Function|s:] Thes|
|00000370| 65 20 66 75 6e 63 74 69 | 6f 6e 73 20 6f 70 65 72 |e functi|ons oper|
|00000380| 61 74 65 20 6f 6e 20 76 | 65 63 74 6f 72 73 2c 0d |ate on v|ectors,.|
|00000390| 20 20 20 20 20 20 20 20 | 20 20 20 65 69 74 68 65 | | eithe|
|000003a0| 72 20 72 6f 77 2d 76 65 | 63 74 6f 72 73 20 28 31 |r row-ve|ctors (1|
|000003b0| 2d 62 79 2d 24 6e 24 29 | 20 6f 72 20 63 6f 6c 75 |-by-$n$)| or colu|
|000003c0| 6d 6e 20 76 65 63 74 6f | 72 73 20 28 24 6d 24 2d |mn vecto|rs ($m$-|
|000003d0| 62 79 2d 31 29 2c 0d 20 | 20 20 20 20 20 20 20 20 |by-1),. | |
|000003e0| 20 20 69 6e 20 74 68 65 | 20 73 61 6d 65 20 66 61 | in the| same fa|
|000003f0| 73 68 69 6f 6e 2e 20 20 | 49 66 20 74 68 65 20 61 |shion. |If the a|
|00000400| 72 67 75 6d 65 6e 74 20 | 69 73 20 61 20 6d 61 74 |rgument |is a mat|
|00000410| 72 69 78 20 77 69 74 68 | 20 62 6f 74 68 0d 20 20 |rix with| both. |
|00000420| 20 20 20 20 20 20 20 20 | 20 64 69 6d 65 6e 73 69 | | dimensi|
|00000430| 6f 6e 73 20 24 3e 20 31 | 24 20 74 68 65 6e 20 74 |ons $> 1|$ then t|
|00000440| 68 65 20 6f 70 65 72 61 | 74 69 6f 6e 20 69 73 20 |he opera|tion is |
|00000450| 70 65 72 66 6f 72 6d 65 | 64 20 69 6e 20 61 0d 20 |performe|d in a. |
|00000460| 20 20 20 20 20 20 20 20 | 20 20 63 6f 6c 75 6d 6e | | column|
|00000470| 2d 77 69 73 65 20 66 61 | 73 68 69 6f 6e 2e 20 53 |-wise fa|shion. S|
|00000480| 6f 6d 65 20 65 78 61 6d | 70 6c 65 73 20 61 72 65 |ome exam|ples are|
|00000490| 3a 20 0d 0d 20 20 20 20 | 20 20 20 20 20 20 20 5c |: .. | \|
|000004a0| 62 65 67 69 6e 7b 74 61 | 62 62 69 6e 67 7d 0d 20 |begin{ta|bbing}. |
|000004b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 66 75 6e 63 | | func|
|000004c0| 74 69 6f 6e 31 20 5c 3d | 20 66 75 6e 63 74 69 6f |tion1 \=| functio|
|000004d0| 6e 32 20 5c 3d 20 66 75 | 6e 63 74 69 6f 6e 32 20 |n2 \= fu|nction2 |
|000004e0| 5c 3d 20 66 75 6e 63 74 | 69 6f 6e 34 20 5c 6b 69 |\= funct|ion4 \ki|
|000004f0| 6c 6c 20 20 20 20 20 20 | 20 20 0d 20 20 20 20 20 |ll | . |
|00000500| 20 20 20 20 20 20 20 20 | 73 75 6d 20 5c 3e 20 70 | |sum \> p|
|00000510| 72 6f 64 20 5c 3e 20 6d | 65 61 6e 20 5c 3e 20 6d |rod \> m|ean \> m|
|00000520| 61 78 20 5c 5c 0d 20 20 | 20 20 20 20 20 20 20 20 |ax \\. | |
|00000530| 20 20 20 6d 69 6e 20 5c | 3e 20 66 66 74 20 5c 3e | min \|> fft \>|
|00000540| 20 73 6f 72 74 20 5c 3e | 20 61 6e 79 20 5c 5c 0d | sort \>| any \\.|
|00000550| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 6e 64 7b | | \end{|
|00000560| 74 61 62 62 69 6e 67 7d | 0d 0d 20 20 20 20 20 20 |tabbing}|.. |
|00000570| 20 20 20 20 20 57 68 65 | 6e 20 75 73 69 6e 67 20 | Whe|n using |
|00000580| 61 20 76 65 63 74 6f 72 | 20 6f 72 69 65 6e 74 65 |a vector| oriente|
|00000590| 64 20 66 75 6e 63 74 69 | 6f 6e 2c 20 6c 69 6b 65 |d functi|on, like|
|000005a0| 20 5c 76 65 72 62 2b 6d | 61 78 28 29 2b 2c 0d 20 | \verb+m|ax()+,. |
|000005b0| 20 20 20 20 20 20 20 20 | 20 20 6f 6e 20 61 20 67 | | on a g|
|000005c0| 65 6e 65 72 61 6c 20 6d | 61 74 72 69 78 2c 20 69 |eneral m|atrix, i|
|000005d0| 74 20 69 73 20 70 6f 73 | 73 69 62 6c 65 20 74 6f |t is pos|sible to|
|000005e0| 20 6f 62 74 61 69 6e 20 | 73 63 61 6c 61 72 0d 20 | obtain |scalar. |
|000005f0| 20 20 20 20 20 20 20 20 | 20 20 71 75 61 6e 74 69 | | quanti|
|00000600| 74 69 65 73 2e 20 46 6f | 72 20 65 78 61 6d 70 6c |ties. Fo|r exampl|
|00000610| 65 20 74 68 65 20 6d 61 | 78 69 6d 75 6d 20 76 61 |e the ma|ximum va|
|00000620| 6c 75 65 20 69 6e 20 61 | 20 6d 61 74 72 69 78 20 |lue in a| matrix |
|00000630| 63 61 6e 0d 20 20 20 20 | 20 20 20 20 20 20 20 62 |can. | b|
|00000640| 65 20 6f 62 74 61 69 6e | 65 64 20 75 73 69 6e 67 |e obtain|ed using|
|00000650| 20 5c 76 65 72 62 2b 6d | 61 78 20 28 6d 61 78 20 | \verb+m|ax (max |
|00000660| 28 61 29 29 2b 2e 20 54 | 68 65 20 66 69 72 73 74 |(a))+. T|he first|
|00000670| 20 63 61 6c 6c 20 74 6f | 0d 20 20 20 20 20 20 20 | call to|. |
|00000680| 20 20 20 20 5c 76 65 72 | 62 2b 6d 61 78 28 29 2b | \ver|b+max()+|
|00000690| 20 72 65 74 75 72 6e 73 | 20 61 20 76 65 63 74 6f | returns| a vecto|
|000006a0| 72 20 6f 66 20 74 68 65 | 20 6d 61 78 69 6d 75 6d |r of the| maximum|
|000006b0| 20 76 61 6c 75 65 73 20 | 66 72 6f 6d 0d 20 20 20 | values |from. |
|000006c0| 20 20 20 20 20 20 20 20 | 65 61 63 68 20 63 6f 6c | |each col|
|000006d0| 75 6d 6e 2c 20 61 6e 64 | 20 74 68 65 20 73 65 63 |umn, and| the sec|
|000006e0| 6f 6e 64 20 63 61 6c 6c | 20 74 6f 20 5c 76 65 72 |ond call| to \ver|
|000006f0| 62 2b 6d 61 78 28 29 2b | 20 72 65 74 75 72 6e 73 |b+max()+| returns|
|00000700| 0d 20 20 20 20 20 20 20 | 20 20 20 20 74 68 65 20 |. | the |
|00000710| 6d 61 78 69 6d 75 6d 20 | 76 61 6c 75 65 20 69 6e |maximum |value in|
|00000720| 20 74 68 65 20 6d 61 74 | 72 69 78 2e 20 20 0d 0d | the mat|rix. ..|
|00000730| 20 20 20 20 20 5c 69 74 | 65 6d 5b 4d 61 74 72 69 | \it|em[Matri|
|00000740| 78 20 46 75 6e 63 74 69 | 6f 6e 73 3a 5d 20 54 68 |x Functi|ons:] Th|
|00000750| 65 73 65 20 66 75 6e 63 | 74 69 6f 6e 73 20 6f 70 |ese func|tions op|
|00000760| 65 72 61 74 65 20 6f 6e | 20 6d 61 74 72 69 63 65 |erate on| matrice|
|00000770| 73 20 61 73 20 61 0d 20 | 20 20 20 20 20 20 20 20 |s as a. | |
|00000780| 20 20 73 69 6e 67 6c 65 | 20 65 6e 74 69 74 79 2e | single| entity.|
|00000790| 20 53 6f 6d 65 20 65 78 | 61 6d 70 6c 65 73 20 61 | Some ex|amples a|
|000007a0| 72 65 3a 0d 0d 20 20 20 | 20 20 20 20 20 20 20 20 |re:.. | |
|000007b0| 5c 62 65 67 69 6e 7b 74 | 61 62 62 69 6e 67 7d 0d |\begin{t|abbing}.|
|000007c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 66 75 6e | | fun|
|000007d0| 63 74 69 6f 6e 31 20 5c | 3d 20 66 75 6e 63 74 69 |ction1 \|= functi|
|000007e0| 6f 6e 32 20 5c 3d 20 66 | 75 6e 63 74 69 6f 6e 32 |on2 \= f|unction2|
|000007f0| 20 5c 3d 20 66 75 6e 63 | 74 69 6f 6e 34 20 5c 6b | \= func|tion4 \k|
|00000800| 69 6c 6c 20 20 20 20 20 | 20 20 20 0d 20 20 20 20 |ill | . |
|00000810| 20 20 20 20 20 20 20 20 | 20 62 61 6c 61 6e 63 65 | | balance|
|00000820| 20 5c 3e 20 63 68 6f 6c | 20 5c 3e 20 64 65 74 20 | \> chol| \> det |
|00000830| 5c 3e 20 65 69 67 20 5c | 5c 0d 20 20 20 20 20 20 |\> eig \|\. |
|00000840| 20 20 20 20 20 20 20 68 | 65 73 73 20 5c 3e 20 69 | h|ess \> i|
|00000850| 6e 76 20 5c 3e 20 6c 75 | 20 5c 3e 20 6e 6f 72 6d |nv \> lu| \> norm|
|00000860| 20 5c 5c 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 | \\. | |
|00000870| 20 70 69 6e 76 20 5c 3e | 20 71 72 20 5c 3e 20 72 | pinv \>| qr \> r|
|00000880| 61 6e 6b 20 5c 3e 20 72 | 63 6f 6e 64 20 5c 5c 0d |ank \> r|cond \\.|
|00000890| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 72 65 73 | | res|
|000008a0| 68 61 70 65 20 5c 3e 20 | 73 6f 6c 76 65 20 5c 3e |hape \> |solve \>|
|000008b0| 20 73 76 64 20 5c 3e 20 | 73 79 6d 6d 20 5c 5c 0d | svd \> |symm \\.|
|000008c0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 6e 64 7b | | \end{|
|000008d0| 74 61 62 62 69 6e 67 7d | 0d 0d 20 20 20 5c 65 6e |tabbing}|.. \en|
|000008e0| 64 7b 64 65 73 63 72 69 | 70 74 69 6f 6e 7d 0d 0d |d{descri|ption}..|
|000008f0| 5c 73 65 63 74 69 6f 6e | 7b 46 75 6e 63 74 69 6f |\section|{Functio|
|00000900| 6e 73 20 61 72 65 20 56 | 61 72 69 61 62 6c 65 73 |ns are V|ariables|
|00000910| 7d 0d 0d 20 20 20 4c 69 | 6b 65 20 6d 61 74 72 69 |}.. Li|ke matri|
|00000920| 63 65 73 2c 20 61 6e 64 | 20 6c 69 73 74 73 20 66 |ces, and| lists f|
|00000930| 75 6e 63 74 69 6f 6e 73 | 20 61 72 65 20 73 74 6f |unctions| are sto|
|00000940| 72 65 64 20 61 73 20 6f | 72 64 69 6e 61 72 79 20 |red as o|rdinary |
|00000950| 76 61 72 69 61 62 6c 65 | 73 0d 20 20 20 69 6e 20 |variable|s. in |
|00000960| 74 68 65 20 73 79 6d 62 | 6f 6c 20 74 61 62 6c 65 |the symb|ol table|
|00000970| 2e 20 41 6e 64 2c 20 6c | 69 6b 65 20 6f 74 68 65 |. And, l|ike othe|
|00000980| 72 20 76 61 72 69 61 62 | 6c 65 73 20 69 6e 20 74 |r variab|les in t|
|00000990| 68 65 20 73 79 6d 62 6f | 6c 20 74 61 62 6c 65 2c |he symbo|l table,|
|000009a0| 0d 20 20 20 66 75 6e 63 | 74 69 6f 6e 73 20 61 72 |. func|tions ar|
|000009b0| 65 20 61 63 63 65 73 73 | 69 62 6c 65 20 61 73 20 |e access|ible as |
|000009c0| 67 6c 6f 62 61 6c 20 76 | 61 72 69 61 62 6c 65 73 |global v|ariables|
|000009d0| 2e 20 46 75 6e 63 74 69 | 6f 6e 27 73 20 74 72 65 |. Functi|on's tre|
|000009e0| 61 74 6d 65 6e 74 0d 20 | 20 20 61 73 20 76 61 72 |atment. | as var|
|000009f0| 69 61 62 6c 65 73 20 65 | 78 70 6c 61 69 6e 73 20 |iables e|xplains |
|00000a00| 74 68 65 20 73 6f 6d 65 | 77 68 61 74 20 70 65 63 |the some|what pec|
|00000a10| 75 6c 69 61 72 20 73 79 | 6e 74 61 78 20 72 65 71 |uliar sy|ntax req|
|00000a20| 75 69 72 65 64 20 74 6f | 0d 20 20 20 63 72 65 61 |uired to|. crea|
|00000a30| 74 65 20 61 6e 64 20 73 | 74 6f 72 65 20 61 20 66 |te and s|tore a f|
|00000a40| 75 6e 63 74 69 6f 6e 2e | 0d 0d 5c 62 65 67 69 6e |unction.|..\begin|
|00000a50| 7b 76 65 72 62 61 74 69 | 6d 7d 0d 3e 20 6c 6f 67 |{verbati|m}.> log|
|00000a60| 73 69 6e 20 3d 20 66 75 | 6e 63 74 69 6f 6e 20 28 |sin = fu|nction (|
|00000a70| 20 78 20 29 20 7b 20 72 | 65 74 75 72 6e 20 6c 6f | x ) { r|eturn lo|
|00000a80| 67 20 28 78 29 20 2e 2a | 20 73 69 6e 20 28 78 29 |g (x) .*| sin (x)|
|00000a90| 3b 20 7d 0d 5c 65 6e 64 | 7b 76 65 72 62 61 74 69 |; }.\end|{verbati|
|00000aa0| 6d 7d 0d 0d 20 20 20 54 | 68 65 20 61 62 6f 76 65 |m}.. T|he above|
|00000ab0| 20 73 74 61 74 65 6d 65 | 6e 74 20 63 72 65 61 74 | stateme|nt creat|
|00000ac0| 65 73 20 61 20 66 75 6e | 63 74 69 6f 6e 2c 20 61 |es a fun|ction, a|
|00000ad0| 6e 64 20 61 73 73 69 67 | 6e 73 20 69 74 20 74 6f |nd assig|ns it to|
|00000ae0| 20 74 68 65 0d 20 20 20 | 76 61 72 69 61 62 6c 65 | the. |variable|
|00000af0| 20 5c 76 65 72 62 2b 6c | 6f 67 73 69 6e 2b 2e 20 | \verb+l|ogsin+. |
|00000b00| 54 68 65 20 66 75 6e 63 | 74 69 6f 6e 20 63 61 6e |The func|tion can|
|00000b10| 20 74 68 65 6e 20 62 65 | 20 75 73 65 64 20 6c 69 | then be| used li|
|00000b20| 6b 65 3a 0d 0d 5c 62 65 | 67 69 6e 7b 76 65 72 62 |ke:..\be|gin{verb|
|00000b30| 61 74 69 6d 7d 0d 3e 20 | 6c 6f 67 73 69 6e 20 28 |atim}.> |logsin (|
|00000b40| 20 32 20 29 0d 20 20 20 | 20 20 30 2e 36 33 0d 5c | 2 ). | 0.63.\|
|00000b50| 65 6e 64 7b 76 65 72 62 | 61 74 69 6d 7d 0d 0d 20 |end{verb|atim}.. |
|00000b60| 20 20 4c 69 6b 65 20 76 | 61 72 69 61 62 6c 65 73 | Like v|ariables|
|00000b70| 20 66 75 6e 63 74 69 6f | 6e 20 63 61 6e 20 62 65 | functio|n can be|
|00000b80| 20 63 6f 70 69 65 64 2c | 20 72 65 2d 61 73 73 69 | copied,| re-assi|
|00000b90| 67 6e 65 64 2c 20 61 6e | 64 20 64 65 73 74 72 6f |gned, an|d destro|
|00000ba0| 79 65 64 2e 20 0d 0d 5c | 62 65 67 69 6e 7b 76 65 |yed. ..\|begin{ve|
|00000bb0| 72 62 61 74 69 6d 7d 0d | 3e 20 2f 2f 20 43 72 65 |rbatim}.|> // Cre|
|00000bc0| 61 74 65 20 61 20 66 75 | 6e 63 74 69 6f 6e 0d 3e |ate a fu|nction.>|
|00000bd0| 20 6c 6f 67 73 69 6e 20 | 3d 20 66 75 6e 63 74 69 | logsin |= functi|
|00000be0| 6f 6e 20 28 20 78 20 29 | 20 7b 20 72 65 74 75 72 |on ( x )| { retur|
|00000bf0| 6e 20 6c 6f 67 20 28 78 | 29 20 2e 2a 20 73 69 6e |n log (x|) .* sin|
|00000c00| 20 28 78 29 3b 20 7d 0d | 3e 0d 3e 20 2f 2f 20 55 | (x); }.|>.> // U|
|00000c10| 73 65 20 69 74 0d 3e 20 | 6c 6f 67 73 69 6e 20 28 |se it.> |logsin (|
|00000c20| 32 29 0d 20 20 20 20 20 | 30 2e 36 33 0d 3e 0d 3e |2). |0.63.>.>|
|00000c30| 20 2f 2f 20 43 6f 70 79 | 20 69 74 20 74 6f 20 74 | // Copy| it to t|
|00000c40| 68 65 20 76 61 72 69 61 | 62 6c 65 20 79 0d 3e 20 |he varia|ble y.> |
|00000c50| 79 20 3d 20 6c 6f 67 73 | 69 6e 0d 3e 20 79 20 28 |y = logs|in.> y (|
|00000c60| 32 29 0d 20 20 20 20 20 | 30 2e 36 33 0d 3e 0d 3e |2). |0.63.>.>|
|00000c70| 20 2f 2f 20 4f 76 65 72 | 77 72 69 74 65 20 69 74 | // Over|write it|
|00000c80| 20 77 69 74 68 20 61 20 | 6d 61 74 72 69 78 0d 3e | with a |matrix.>|
|00000c90| 20 6c 6f 67 73 69 6e 20 | 3d 20 72 61 6e 64 28 33 | logsin |= rand(3|
|00000ca0| 2c 32 29 0d 20 6c 6f 67 | 73 69 6e 20 3d 0d 20 6d |,2). log|sin =. m|
|00000cb0| 61 74 72 69 78 20 63 6f | 6c 75 6d 6e 73 20 31 20 |atrix co|lumns 1 |
|00000cc0| 74 68 72 75 20 32 0d 20 | 20 20 20 20 20 20 20 31 |thru 2. | 1|
|00000cd0| 20 20 20 20 20 20 30 2e | 33 33 33 20 20 0d 20 20 | 0.|333 . |
|00000ce0| 20 20 30 2e 39 37 35 20 | 20 20 20 20 30 2e 30 33 | 0.975 | 0.03|
|00000cf0| 36 39 20 20 0d 20 20 20 | 20 30 2e 36 34 37 20 20 |69 . | 0.647 |
|00000d00| 20 20 20 20 30 2e 31 36 | 32 20 20 0d 3e 0d 3e 20 | 0.16|2 .>.> |
|00000d10| 2f 2f 20 43 68 65 63 6b | 20 74 68 61 74 20 79 20 |// Check| that y |
|00000d20| 73 74 69 6c 6c 20 69 73 | 20 61 20 66 75 6e 63 74 |still is| a funct|
|00000d30| 69 6f 6e 0d 3e 20 79 20 | 28 32 29 0d 20 20 20 20 |ion.> y |(2). |
|00000d40| 20 30 2e 36 33 0d 5c 65 | 6e 64 7b 76 65 72 62 61 | 0.63.\e|nd{verba|
|00000d50| 74 69 6d 7d 0d 0d 20 20 | 20 49 66 20 79 6f 75 20 |tim}.. | If you |
|00000d60| 74 72 79 20 72 65 2d 61 | 73 73 69 67 6e 69 6e 67 |try re-a|ssigning|
|00000d70| 20 61 20 62 75 69 6c 74 | 2d 69 6e 20 66 75 6e 63 | a built|-in func|
|00000d80| 74 69 6f 6e 20 79 6f 75 | 20 77 69 6c 6c 20 67 65 |tion you| will ge|
|00000d90| 74 20 61 20 72 75 6e 2d | 74 69 6d 65 0d 20 20 20 |t a run-|time. |
|00000da0| 65 72 72 6f 72 20 6d 65 | 73 73 61 67 65 2e 20 54 |error me|ssage. T|
|00000db0| 68 65 20 62 75 69 6c 74 | 2d 69 6e 20 66 75 6e 63 |he built|-in func|
|00000dc0| 74 69 6f 6e 73 2c 20 74 | 68 6f 73 65 20 74 68 61 |tions, t|hose tha|
|00000dd0| 74 20 61 72 65 20 70 72 | 6f 67 72 61 6d 6d 65 64 |t are pr|ogrammed|
|00000de0| 20 69 6e 0d 20 20 20 43 | 2c 20 61 72 65 20 61 20 | in. C|, are a |
|00000df0| 70 65 72 6d 61 6e 65 6e | 74 20 70 61 72 74 20 6f |permanen|t part o|
|00000e00| 66 20 74 68 65 20 65 6e | 76 69 72 6f 6e 6d 65 6e |f the en|vironmen|
|00000e10| 74 2e 20 53 6f 20 74 68 | 61 74 20 75 73 65 72 73 |t. So th|at users|
|00000e20| 20 6d 61 79 0d 20 20 20 | 61 6c 77 61 79 73 20 72 | may. |always r|
|00000e30| 65 6c 79 20 6f 6e 20 74 | 68 65 69 72 20 61 76 61 |ely on t|heir ava|
|00000e40| 69 6c 61 62 69 6c 69 74 | 79 2c 20 74 68 65 79 20 |ilabilit|y, they |
|00000e50| 63 61 6e 6e 6f 74 20 62 | 65 20 72 65 2d 61 73 73 |cannot b|e re-ass|
|00000e60| 69 67 6e 65 64 2c 20 6f | 72 0d 20 20 20 63 6f 70 |igned, o|r. cop|
|00000e70| 69 65 64 2e 20 0d 0d 20 | 20 20 56 61 72 69 61 62 |ied. .. | Variab|
|00000e80| 6c 65 73 20 74 68 61 74 | 20 72 65 70 72 65 73 65 |les that| represe|
|00000e90| 6e 74 20 66 75 6e 63 74 | 69 6f 6e 73 20 63 61 6e |nt funct|ions can|
|00000ea0| 20 61 6c 73 6f 20 62 65 | 20 70 61 72 74 20 6f 66 | also be| part of|
|00000eb0| 20 6c 69 73 74 0d 20 20 | 20 6f 62 6a 65 63 74 73 | list. | objects|
|00000ec0| 2e 20 53 6f 6d 65 74 69 | 6d 65 73 20 69 74 20 63 |. Someti|mes it c|
|00000ed0| 61 6e 20 62 65 20 75 73 | 65 66 75 6c 20 74 6f 20 |an be us|eful to |
|00000ee0| 67 72 6f 75 70 20 66 75 | 6e 63 74 69 6f 6e 73 20 |group fu|nctions |
|00000ef0| 74 68 61 74 20 73 65 72 | 76 65 20 61 0d 20 20 20 |that ser|ve a. |
|00000f00| 73 69 6d 69 6c 61 72 20 | 70 75 72 70 6f 73 65 2c |similar |purpose,|
|00000f10| 20 6f 72 20 70 65 72 66 | 6f 72 6d 20 64 69 66 66 | or perf|orm diff|
|00000f20| 65 72 65 6e 74 20 70 61 | 72 74 73 20 6f 66 20 61 |erent pa|rts of a|
|00000f30| 20 6c 61 72 67 65 72 20 | 70 72 6f 63 65 64 75 72 | larger |procedur|
|00000f40| 65 2e 0d 0d 5c 62 65 67 | 69 6e 7b 76 65 72 62 61 |e...\beg|in{verba|
|00000f50| 74 69 6d 7d 0d 6c 69 73 | 74 20 3d 20 3c 3c 20 6c |tim}.lis|t = << l|
|00000f60| 6f 67 73 69 6e 20 3d 20 | 6c 6f 67 73 69 6e 20 3e |ogsin = |logsin >|
|00000f70| 3e 0d 20 20 20 6c 6f 67 | 73 69 6e 20 20 20 20 20 |>. log|sin |
|00000f80| 20 20 0d 3e 20 6c 69 73 | 74 2e 6c 6f 67 73 69 6e | .> lis|t.logsin|
|00000f90| 20 28 32 29 0d 20 20 20 | 20 20 30 2e 36 33 0d 3e | (2). | 0.63.>|
|00000fa0| 20 6c 69 73 74 2e 65 78 | 70 73 69 6e 20 3d 20 66 | list.ex|psin = f|
|00000fb0| 75 6e 63 74 69 6f 6e 20 | 28 20 78 20 29 20 7b 20 |unction |( x ) { |
|00000fc0| 72 65 74 75 72 6e 20 65 | 78 70 20 28 78 29 20 2e |return e|xp (x) .|
|00000fd0| 2a 20 73 69 6e 20 28 78 | 29 3b 20 7d 0d 20 20 20 |* sin (x|); }. |
|00000fe0| 65 78 70 73 69 6e 20 20 | 20 20 20 20 20 6c 6f 67 |expsin | log|
|00000ff0| 73 69 6e 20 20 20 20 20 | 20 20 0d 3e 20 6c 69 73 |sin | .> lis|
|00001000| 74 2e 65 78 70 73 69 6e | 20 28 32 29 0d 20 20 20 |t.expsin| (2). |
|00001010| 20 20 36 2e 37 32 0d 5c | 65 6e 64 7b 76 65 72 62 | 6.72.\|end{verb|
|00001020| 61 74 69 6d 7d 0d 0d 5c | 73 65 63 74 69 6f 6e 7b |atim}..\|section{|
|00001030| 46 75 6e 63 74 69 6f 6e | 20 53 79 6e 74 61 78 7d |Function| Syntax}|
|00001040| 0d 0d 20 20 20 54 68 65 | 20 66 75 6e 63 74 69 6f |.. The| functio|
|00001050| 6e 20 73 79 6e 74 61 78 | 20 69 73 20 66 61 69 72 |n syntax| is fair|
|00001060| 6c 79 20 73 69 6d 70 6c | 65 2e 20 54 68 65 20 62 |ly simpl|e. The b|
|00001070| 61 73 69 63 20 66 6f 72 | 6d 20 6f 66 20 61 20 66 |asic for|m of a f|
|00001080| 75 6e 63 74 69 6f 6e 0d | 20 20 20 69 73 3a 0d 0d |unction.| is:..|
|00001090| 20 20 20 5c 62 65 67 69 | 6e 7b 74 61 62 62 69 6e | \begi|n{tabbin|
|000010a0| 67 7d 0d 20 20 20 20 31 | 32 33 34 35 36 20 5c 3d |g}. 1|23456 \=|
|000010b0| 20 31 32 33 34 20 5c 3d | 20 20 5c 6b 69 6c 6c 0d | 1234 \=| \kill.|
|000010c0| 0d 20 20 20 20 5c 3e 20 | 66 75 6e 63 74 69 6f 6e |. \> |function|
|000010d0| 20 5c 20 28 5c 20 20 7b | 5c 69 74 20 61 72 67 75 | \ (\ {|\it argu|
|000010e0| 6d 65 6e 74 20 6c 69 73 | 74 7d 20 5c 20 29 20 5c |ment lis|t} \ ) \|
|000010f0| 5c 0d 20 20 20 20 5c 3e | 20 5c 7b 20 20 20 20 20 |\. \>| \{ |
|00001100| 20 20 20 20 20 20 20 20 | 20 20 5c 5c 0d 20 20 20 | | \\. |
|00001110| 20 5c 3e 20 5c 3e 20 6c | 6f 63 61 6c 20 5c 20 28 | \> \> l|ocal \ (|
|00001120| 5c 20 7b 5c 69 74 20 6c | 6f 63 61 6c 20 76 61 72 |\ {\it l|ocal var|
|00001130| 69 61 62 6c 65 20 6c 69 | 73 74 7d 20 5c 20 29 20 |iable li|st} \ ) |
|00001140| 5c 5c 0d 20 20 20 20 5c | 3e 20 5c 3e 20 20 20 20 |\\. \|> \> |
|00001150| 20 20 20 20 20 20 20 20 | 20 20 20 5c 5c 0d 20 20 | | \\. |
|00001160| 20 20 5c 3e 20 5c 3e 20 | 7b 5c 69 74 20 73 74 61 | \> \> |{\it sta|
|00001170| 74 65 6d 65 6e 74 73 7d | 20 20 20 20 5c 5c 0d 20 |tements}| \\. |
|00001180| 20 20 20 5c 3e 20 5c 3e | 20 20 20 20 20 20 20 20 | \> \>| |
|00001190| 20 20 20 20 20 20 20 5c | 5c 0d 20 20 20 20 5c 3e | \|\. \>|
|000011a0| 20 5c 3e 20 72 65 74 75 | 72 6e 20 7b 5c 69 74 20 | \> retu|rn {\it |
|000011b0| 65 78 70 72 65 73 73 69 | 6f 6e 20 7d 20 5c 5c 0d |expressi|on } \\.|
|000011c0| 20 20 20 20 5c 3e 20 5c | 7d 20 20 20 20 20 20 20 | \> \|} |
|000011d0| 20 20 20 20 20 20 20 20 | 5c 5c 0d 20 20 20 5c 65 | |\\. \e|
|000011e0| 6e 64 7b 74 61 62 62 69 | 6e 67 7d 0d 0d 20 20 20 |nd{tabbi|ng}.. |
|000011f0| 54 68 65 20 5c 76 65 72 | 62 2b 6c 6f 63 61 6c 2b |The \ver|b+local+|
|00001200| 2c 20 61 6e 64 20 5c 76 | 65 72 62 2b 72 65 74 75 |, and \v|erb+retu|
|00001210| 72 6e 2b 20 73 74 61 74 | 65 6d 65 6e 74 73 20 61 |rn+ stat|ements a|
|00001220| 72 65 20 6f 70 74 69 6f | 6e 61 6c 2e 0d 0d 20 20 |re optio|nal... |
|00001230| 20 49 66 20 61 20 73 79 | 6e 74 61 78 20 65 72 72 | If a sy|ntax err|
|00001240| 6f 72 20 69 73 20 65 6e | 63 6f 75 6e 74 65 72 65 |or is en|countere|
|00001250| 64 20 77 68 69 6c 65 20 | 74 68 65 20 66 75 6e 63 |d while |the func|
|00001260| 74 69 6f 6e 20 69 73 20 | 62 65 69 6e 67 0d 20 20 |tion is |being. |
|00001270| 20 65 6e 74 65 72 65 64 | 20 28 72 65 61 64 29 2c | entered| (read),|
|00001280| 20 64 65 66 69 6e 69 74 | 69 6f 6e 20 6f 66 20 74 | definit|ion of t|
|00001290| 68 65 20 66 75 6e 63 74 | 69 6f 6e 20 6d 75 73 74 |he funct|ion must|
|000012a0| 20 62 65 67 69 6e 20 61 | 67 61 69 6e 2c 20 66 72 | begin a|gain, fr|
|000012b0| 6f 6d 0d 20 20 20 74 68 | 65 20 76 65 72 79 20 62 |om. th|e very b|
|000012c0| 65 67 69 6e 6e 69 6e 67 | 2e 0d 0d 5c 73 75 62 73 |eginning|...\subs|
|000012d0| 65 63 74 69 6f 6e 7b 4c | 6f 63 61 6c 20 53 74 61 |ection{L|ocal Sta|
|000012e0| 74 65 6d 65 6e 74 7d 0d | 0d 20 20 20 54 68 65 20 |tement}.|. The |
|000012f0| 6c 6f 63 61 6c 20 73 74 | 61 74 65 6d 65 6e 74 20 |local st|atement |
|00001300| 69 73 20 6f 70 74 69 6f | 6e 61 6c 2e 20 49 66 20 |is optio|nal. If |
|00001310| 69 74 20 69 73 20 70 72 | 65 73 65 6e 74 20 69 74 |it is pr|esent it|
|00001320| 20 6d 75 73 74 20 62 65 | 20 74 68 65 0d 20 20 20 | must be| the. |
|00001330| 66 69 72 73 74 20 73 74 | 61 74 65 6d 65 6e 74 20 |first st|atement |
|00001340| 69 6e 20 74 68 65 20 66 | 75 6e 63 74 69 6f 6e 2e |in the f|unction.|
|00001350| 20 4f 6e 6c 79 20 6f 6e | 65 20 6c 6f 63 61 6c 20 | Only on|e local |
|00001360| 73 74 61 74 65 6d 65 6e | 74 20 69 73 0d 20 20 20 |statemen|t is. |
|00001370| 61 6c 6c 6f 77 65 64 2e | 0d 0d 5c 73 75 62 73 65 |allowed.|..\subse|
|00001380| 63 74 69 6f 6e 7b 52 65 | 74 75 72 6e 20 53 74 61 |ction{Re|turn Sta|
|00001390| 74 65 6d 65 6e 74 7d 0d | 0d 20 20 20 54 68 65 20 |tement}.|. The |
|000013a0| 72 65 74 75 72 6e 20 73 | 74 61 74 65 6d 65 6e 74 |return s|tatement|
|000013b0| 20 69 73 20 6f 70 74 69 | 6f 6e 61 6c 2e 20 54 68 | is opti|onal. Th|
|000013c0| 65 72 65 20 61 72 65 20 | 6e 6f 20 72 65 73 74 72 |ere are |no restr|
|000013d0| 69 63 74 69 6f 6e 73 20 | 6f 6e 20 74 68 65 0d 20 |ictions |on the. |
|000013e0| 20 20 6e 75 6d 62 65 72 | 20 6f 66 20 72 65 74 75 | number| of retu|
|000013f0| 72 6e 20 73 74 61 74 65 | 6d 65 6e 74 73 2c 20 6f |rn state|ments, o|
|00001400| 72 20 74 68 65 69 72 20 | 70 6c 61 63 65 6d 65 6e |r their |placemen|
|00001410| 74 2e 20 41 20 66 75 6e | 63 74 69 6f 6e 20 63 61 |t. A fun|ction ca|
|00001420| 6e 0d 20 20 20 72 65 74 | 75 72 6e 20 66 72 6f 6d |n. ret|urn from|
|00001430| 20 61 6e 79 20 70 6f 69 | 6e 74 20 69 6e 20 69 74 | any poi|nt in it|
|00001440| 27 73 20 65 78 65 63 75 | 74 69 6f 6e 2e 0d 0d 5c |'s execu|tion...\|
|00001450| 73 65 63 74 69 6f 6e 7b | 46 75 6e 63 74 69 6f 6e |section{|Function|
|00001460| 20 53 63 6f 70 69 6e 67 | 20 52 75 6c 65 73 7d 0d | Scoping| Rules}.|
|00001470| 0d 20 20 20 5c 52 4c 61 | 42 5c 27 73 20 73 63 6f |. \RLa|B\'s sco|
|00001480| 70 69 6e 67 20 72 75 6c | 65 73 20 77 69 6c 6c 20 |ping rul|es will |
|00001490| 73 65 65 6d 20 73 6f 6d | 65 77 68 61 74 20 70 65 |seem som|ewhat pe|
|000014a0| 63 75 6c 69 61 72 20 69 | 66 20 79 6f 75 20 64 6f |culiar i|f you do|
|000014b0| 6e 27 74 0d 20 20 20 72 | 65 6d 65 6d 62 65 72 20 |n't. r|emember |
|000014c0| 74 68 61 74 3a 20 60 60 | 65 76 65 72 79 74 68 69 |that: ``|everythi|
|000014d0| 6e 67 20 69 73 20 61 20 | 76 61 72 69 61 62 6c 65 |ng is a |variable|
|000014e0| 27 27 2e 20 0d 0d 20 20 | 20 42 79 20 64 65 66 61 |''. .. | By defa|
|000014f0| 75 6c 74 2c 20 61 6c 6c | 20 76 61 72 69 61 62 6c |ult, all| variabl|
|00001500| 65 73 20 75 73 65 64 20 | 69 6e 73 69 64 65 20 61 |es used |inside a|
|00001510| 20 66 75 6e 63 74 69 6f | 6e 2c 20 77 69 74 68 20 | functio|n, with |
|00001520| 74 68 65 0d 20 20 20 65 | 78 63 65 70 74 69 6f 6e |the. e|xception|
|00001530| 20 6f 66 20 61 72 67 75 | 6d 65 6e 74 73 2c 20 61 | of argu|ments, a|
|00001540| 6e 64 20 6c 6f 63 61 6c | 20 76 61 72 69 61 62 6c |nd local| variabl|
|00001550| 65 73 2c 20 61 72 65 20 | 67 6c 6f 62 61 6c 2e 20 |es, are |global. |
|00001560| 54 68 69 73 0d 20 20 20 | 61 6c 6c 6f 77 73 20 75 |This. |allows u|
|00001570| 73 65 72 73 20 74 6f 20 | 68 61 76 65 20 61 63 63 |sers to |have acc|
|00001580| 65 73 73 20 74 6f 20 74 | 68 65 20 6f 74 68 65 72 |ess to t|he other|
|00001590| 20 75 73 65 72 20 61 6e | 64 20 62 75 69 6c 74 69 | user an|d builti|
|000015a0| 6e 20 66 75 6e 63 74 69 | 6f 6e 73 0d 20 20 20 77 |n functi|ons. w|
|000015b0| 69 74 68 6f 75 74 20 73 | 70 65 63 69 61 6c 20 64 |ithout s|pecial d|
|000015c0| 65 63 6c 61 72 61 74 69 | 6f 6e 73 2c 20 6f 72 20 |eclarati|ons, or |
|000015d0| 63 6f 6d 70 6c 69 63 61 | 74 65 64 20 73 63 6f 70 |complica|ted scop|
|000015e0| 69 6e 67 20 72 75 6c 65 | 73 2e 0d 0d 20 20 20 56 |ing rule|s... V|
|000015f0| 61 72 69 61 62 6c 65 73 | 20 69 6e 20 61 20 66 75 |ariables| in a fu|
|00001600| 6e 63 74 69 6f 6e 20 61 | 72 65 20 72 65 73 6f 6c |nction a|re resol|
|00001610| 76 65 64 20 62 79 3a 0d | 0d 20 20 20 5c 62 65 67 |ved by:.|. \beg|
|00001620| 69 6e 7b 65 6e 75 6d 65 | 72 61 74 65 7d 0d 20 20 |in{enume|rate}. |
|00001630| 20 20 20 20 5c 69 74 65 | 6d 20 4c 6f 6f 6b 69 6e | \ite|m Lookin|
|00001640| 67 20 69 6e 20 74 68 65 | 20 66 75 63 74 69 6f 6e |g in the| fuction|
|00001650| 20 61 72 67 75 6d 65 6e | 74 73 2c 0d 20 20 20 20 | argumen|ts,. |
|00001660| 20 20 5c 69 74 65 6d 20 | 4c 6f 6f 6b 69 6e 67 20 | \item |Looking |
|00001670| 69 6e 20 74 68 65 20 6c | 6f 63 61 6c 20 76 61 72 |in the l|ocal var|
|00001680| 69 61 62 6c 65 73 2c 0d | 20 20 20 20 20 20 5c 69 |iables,.| \i|
|00001690| 74 65 6d 20 4c 6f 6f 6b | 69 6e 67 20 69 6e 20 74 |tem Look|ing in t|
|000016a0| 68 65 20 66 69 6c 65 27 | 73 20 73 74 61 74 69 63 |he file'|s static|
|000016b0| 20 76 61 72 69 61 62 6c | 65 73 2c 0d 20 20 20 20 | variabl|es,. |
|000016c0| 20 20 5c 69 74 65 6d 20 | 4c 6f 6f 6b 69 6e 67 20 | \item |Looking |
|000016d0| 69 6e 20 74 68 65 20 73 | 79 6d 62 6f 6c 2d 74 61 |in the s|ymbol-ta|
|000016e0| 62 6c 65 2e 0d 20 20 20 | 5c 65 6e 64 7b 65 6e 75 |ble.. |\end{enu|
|000016f0| 6d 65 72 61 74 65 7d 0d | 0d 5c 73 75 62 73 65 63 |merate}.|.\subsec|
|00001700| 74 69 6f 6e 7b 46 75 6e | 63 74 69 6f 6e 20 41 72 |tion{Fun|ction Ar|
|00001710| 67 75 6d 65 6e 74 73 7d | 0d 0d 20 20 20 41 72 67 |guments}|.. Arg|
|00001720| 75 6d 65 6e 74 73 20 61 | 72 65 20 70 61 73 73 65 |uments a|re passe|
|00001730| 64 20 62 79 20 72 65 66 | 65 72 65 6e 63 65 2e 20 |d by ref|erence. |
|00001740| 54 68 75 73 2c 20 77 68 | 65 6e 20 61 20 66 75 6e |Thus, wh|en a fun|
|00001750| 63 74 69 6f 6e 20 61 72 | 67 75 6d 65 6e 74 0d 20 |ction ar|gument. |
|00001760| 20 20 69 73 20 6d 6f 64 | 69 66 69 65 64 2c 20 74 | is mod|ified, t|
|00001770| 68 65 20 6f 62 6a 65 63 | 74 20 69 6e 20 74 68 65 |he objec|t in the|
|00001780| 20 63 61 6c 6c 65 72 27 | 73 20 73 63 6f 70 65 20 | caller'|s scope |
|00001790| 67 65 74 73 20 6d 6f 64 | 69 66 69 65 64 0d 20 20 |gets mod|ified. |
|000017a0| 20 64 69 72 65 63 74 6c | 79 2e 0d 0d 20 20 20 41 | directl|y... A|
|000017b0| 20 66 75 6e 63 74 69 6f | 6e 20 63 61 6e 20 62 65 | functio|n can be|
|000017c0| 20 63 61 6c 6c 65 64 20 | 77 69 74 68 20 66 65 77 | called |with few|
|000017d0| 65 72 20 61 72 67 75 6d | 65 6e 74 73 20 74 68 61 |er argum|ents tha|
|000017e0| 6e 20 73 70 65 63 69 66 | 69 65 64 20 69 6e 20 74 |n specif|ied in t|
|000017f0| 68 65 0d 20 20 20 64 65 | 66 69 6e 69 74 69 6f 6e |he. de|finition|
|00001800| 2e 20 57 68 65 6e 20 74 | 68 69 73 20 73 69 74 75 |. When t|his situ|
|00001810| 61 74 69 6f 6e 20 6f 63 | 63 75 72 73 2c 20 72 6c |ation oc|curs, rl|
|00001820| 61 62 20 70 61 64 73 20 | 74 68 65 20 61 72 67 75 |ab pads |the argu|
|00001830| 6d 65 6e 74 20 6c 69 73 | 74 0d 20 20 20 77 69 74 |ment lis|t. wit|
|00001840| 68 20 65 78 74 72 61 20 | 75 6e 64 65 66 69 6e 65 |h extra |undefine|
|00001850| 64 20 76 61 72 69 61 62 | 6c 65 73 2e 20 54 68 65 |d variab|les. The|
|00001860| 73 65 20 75 6e 64 65 66 | 69 6e 65 64 20 61 72 67 |se undef|ined arg|
|00001870| 75 6d 65 6e 74 73 20 63 | 61 6e 20 62 65 0d 20 20 |uments c|an be. |
|00001880| 20 64 65 74 65 63 74 65 | 64 20 77 69 74 68 20 74 | detecte|d with t|
|00001890| 68 65 20 5c 76 65 72 62 | 2b 65 78 69 73 74 2b 20 |he \verb|+exist+ |
|000018a0| 66 75 6e 63 74 69 6f 6e | 2e 20 53 6f 6d 65 74 69 |function|. Someti|
|000018b0| 6d 65 73 20 66 75 6e 63 | 74 69 6f 6e 73 20 61 72 |mes func|tions ar|
|000018c0| 65 0d 20 20 20 77 72 69 | 74 74 65 6e 20 74 6f 20 |e. wri|tten to |
|000018d0| 75 73 65 20 60 60 64 65 | 66 61 75 6c 74 27 27 20 |use ``de|fault'' |
|000018e0| 76 61 6c 75 65 73 20 66 | 6f 72 20 61 72 67 75 6d |values f|or argum|
|000018f0| 65 6e 74 73 20 74 68 61 | 74 20 61 72 65 0d 20 20 |ents tha|t are. |
|00001900| 20 75 6e 73 70 65 63 69 | 66 69 65 64 2e 20 46 6f | unspeci|fied. Fo|
|00001910| 72 20 65 78 61 6d 70 6c | 65 3a 20 69 6e 20 5c 76 |r exampl|e: in \v|
|00001920| 65 72 62 2b 6f 64 65 37 | 38 2e 72 2b 20 74 68 65 |erb+ode7|8.r+ the|
|00001930| 20 61 72 67 75 6d 65 6e | 74 20 76 61 72 69 61 62 | argumen|t variab|
|00001940| 6c 65 0d 20 20 20 5c 76 | 65 72 62 2b 74 6f 6c 2b |le. \v|erb+tol+|
|00001950| 20 69 73 20 73 65 74 20 | 74 6f 20 74 68 65 20 60 | is set |to the `|
|00001960| 60 64 65 66 61 75 6c 74 | 27 27 20 76 61 6c 75 65 |`default|'' value|
|00001970| 20 6f 66 20 5c 76 65 72 | 62 2b 31 2e 65 2d 36 2b | of \ver|b+1.e-6+|
|00001980| 20 69 66 0d 20 20 20 5c | 76 65 72 62 2b 74 6f 6c | if. \|verb+tol|
|00001990| 2b 20 69 73 20 5c 76 65 | 72 62 2b 55 4e 44 45 46 |+ is \ve|rb+UNDEF|
|000019a0| 49 4e 45 44 2b 2e 20 4e | 6f 74 65 20 74 68 61 74 |INED+. N|ote that|
|000019b0| 20 61 6e 20 75 6e 64 65 | 66 69 6e 65 64 20 76 61 | an unde|fined va|
|000019c0| 72 69 61 62 6c 65 0d 20 | 20 20 64 6f 65 73 20 6e |riable. | does n|
|000019d0| 6f 74 20 65 78 69 73 74 | 2e 20 54 68 65 72 65 66 |ot exist|. Theref|
|000019e0| 6f 72 65 2c 20 74 68 65 | 20 5c 76 65 72 62 2b 65 |ore, the| \verb+e|
|000019f0| 78 69 73 74 2b 20 66 75 | 6e 63 74 69 6f 6e 20 77 |xist+ fu|nction w|
|00001a00| 69 6c 6c 20 72 65 74 75 | 72 6e 0d 20 20 20 5c 76 |ill retu|rn. \v|
|00001a10| 65 72 62 2b 30 2b 20 69 | 66 20 69 74 27 73 20 61 |erb+0+ i|f it's a|
|00001a20| 72 67 75 6d 65 6e 74 20 | 69 73 20 75 6e 64 65 66 |rgument |is undef|
|00001a30| 69 6e 65 64 2e 20 54 68 | 65 72 65 20 61 72 65 20 |ined. Th|ere are |
|00001a40| 74 77 6f 20 6d 65 74 68 | 6f 64 73 20 66 6f 72 0d |two meth|ods for.|
|00001a50| 20 20 20 69 6e 76 6f 6b | 69 6e 67 20 61 20 66 75 | invok|ing a fu|
|00001a60| 6e 63 74 69 6f 6e 20 61 | 6e 64 20 73 70 65 63 69 |nction a|nd speci|
|00001a70| 66 69 79 69 6e 67 20 75 | 6e 64 65 66 69 6e 65 64 |fiying u|ndefined|
|00001a80| 20 61 72 67 75 6d 65 6e | 74 73 2e 20 20 45 69 74 | argumen|ts. Eit|
|00001a90| 68 65 72 0d 20 20 20 74 | 68 65 20 61 72 67 75 6d |her. t|he argum|
|00001aa0| 65 6e 74 73 20 63 61 6e | 20 62 65 20 75 6e 73 70 |ents can| be unsp|
|00001ab0| 65 63 69 66 69 65 64 20 | 61 6e 64 20 74 68 65 20 |ecified |and the |
|00001ac0| 61 72 67 75 6d 65 6e 74 | 20 6c 69 73 74 20 77 69 |argument| list wi|
|00001ad0| 6c 6c 20 62 65 0d 20 20 | 20 70 61 64 64 65 64 20 |ll be. | padded |
|00001ae0| 77 69 74 68 20 75 6e 64 | 65 66 69 6e 65 64 20 76 |with und|efined v|
|00001af0| 61 72 69 61 62 6c 65 73 | 2c 20 6f 72 20 74 68 65 |ariables|, or the|
|00001b00| 20 61 72 67 75 6d 65 6e | 74 28 73 29 20 63 61 6e | argumen|t(s) can|
|00001b10| 20 62 65 0d 20 20 20 65 | 78 70 6c 69 63 69 74 6c | be. e|xplicitl|
|00001b20| 79 20 73 70 65 63 69 66 | 69 65 64 20 61 73 20 75 |y specif|ied as u|
|00001b30| 6e 64 65 66 69 6e 65 64 | 20 62 79 20 75 73 69 6e |ndefined| by usin|
|00001b40| 67 20 61 20 76 61 72 69 | 61 62 6c 65 20 74 68 61 |g a vari|able tha|
|00001b50| 74 20 69 73 0d 20 20 20 | 75 6e 64 65 66 69 6e 65 |t is. |undefine|
|00001b60| 64 2e 20 54 68 65 20 76 | 61 72 69 61 62 6c 65 20 |d. The v|ariable |
|00001b70| 5c 76 65 72 62 2b 55 4e | 44 45 46 2b 20 69 73 20 |\verb+UN|DEF+ is |
|00001b80| 63 6f 6d 6d 6f 6e 6c 79 | 20 75 73 65 64 20 66 6f |commonly| used fo|
|00001b90| 72 20 74 68 69 73 2c 20 | 62 75 74 0d 20 20 20 74 |r this, |but. t|
|00001ba0| 68 65 20 63 68 6f 69 63 | 65 20 6f 66 20 75 6e 64 |he choic|e of und|
|00001bb0| 65 66 69 6e 65 64 20 76 | 61 72 69 61 62 6c 65 20 |efined v|ariable |
|00001bc0| 6e 61 6d 65 28 73 29 20 | 69 73 20 61 72 62 69 74 |name(s) |is arbit|
|00001bd0| 72 61 72 79 2e 0d 0d 20 | 20 20 41 20 66 75 6e 63 |rary... | A func|
|00001be0| 74 69 6f 6e 20 63 61 6e | 6e 6f 74 20 62 65 20 63 |tion can|not be c|
|00001bf0| 61 6c 6c 65 64 20 77 69 | 74 68 20 6d 6f 72 65 20 |alled wi|th more |
|00001c00| 61 72 67 75 6d 65 6e 74 | 73 20 74 68 61 6e 20 73 |argument|s than s|
|00001c10| 70 65 63 69 66 69 65 64 | 20 69 6e 0d 20 20 20 74 |pecified| in. t|
|00001c20| 68 65 20 66 75 6e 63 74 | 69 6f 6e 20 64 65 66 69 |he funct|ion defi|
|00001c30| 6e 69 74 69 6f 6e 2e 20 | 49 66 20 79 6f 75 20 61 |nition. |If you a|
|00001c40| 74 74 65 6d 70 74 20 74 | 6f 20 64 6f 20 73 6f 2c |ttempt t|o do so,|
|00001c50| 20 61 20 72 75 6e 2d 74 | 69 6d 65 20 65 72 72 6f | a run-t|ime erro|
|00001c60| 72 0d 20 20 20 77 69 6c | 6c 20 72 65 73 75 6c 74 |r. wil|l result|
|00001c70| 2e 0d 0d 20 20 20 46 75 | 6e 63 74 69 6f 6e 20 61 |... Fu|nction a|
|00001c80| 72 67 75 6d 65 6e 74 20 | 74 79 70 65 73 20 61 72 |rgument |types ar|
|00001c90| 65 20 6e 6f 74 20 73 70 | 65 63 69 66 69 65 64 20 |e not sp|ecified |
|00001ca0| 64 75 72 69 6e 67 20 64 | 65 66 69 6e 69 74 69 6f |during d|efinitio|
|00001cb0| 6e 2e 20 57 68 65 6e 0d | 20 20 20 77 72 69 74 69 |n. When.| writi|
|00001cc0| 6e 67 20 60 60 72 6f 62 | 75 73 74 27 27 20 66 75 |ng ``rob|ust'' fu|
|00001cd0| 6e 63 74 69 6f 6e 73 20 | 74 68 65 20 61 75 74 68 |nctions |the auth|
|00001ce0| 6f 72 20 73 68 6f 75 6c | 64 20 74 61 6b 65 20 73 |or shoul|d take s|
|00001cf0| 6f 6d 65 20 63 61 72 65 | 20 74 6f 0d 20 20 20 63 |ome care| to. c|
|00001d00| 68 65 63 6b 20 74 68 61 | 74 20 74 68 65 20 66 75 |heck tha|t the fu|
|00001d10| 6e 63 74 69 6f 6e 20 61 | 72 67 75 6d 65 6e 74 28 |nction a|rgument(|
|00001d20| 73 29 20 61 72 65 20 6f | 66 20 74 68 65 20 63 6f |s) are o|f the co|
|00001d30| 72 72 65 63 74 20 74 79 | 70 65 2e 0d 20 20 20 46 |rrect ty|pe.. F|
|00001d40| 75 72 74 68 65 72 6d 6f | 72 65 2c 20 74 68 65 20 |urthermo|re, the |
|00001d50| 64 6f 63 75 6d 65 6e 74 | 61 74 69 6f 6e 20 28 63 |document|ation (c|
|00001d60| 6f 6d 6d 65 6e 74 73 29 | 20 73 68 6f 75 6c 64 20 |omments)| should |
|00001d70| 63 6c 65 61 72 6c 79 20 | 73 74 61 74 65 20 74 68 |clearly |state th|
|00001d80| 65 0d 20 20 20 72 65 71 | 75 69 73 69 74 65 20 61 |e. req|uisite a|
|00001d90| 72 67 75 6d 65 6e 74 20 | 74 79 70 65 73 20 69 66 |rgument |types if|
|00001da0| 20 6e 65 63 65 73 73 61 | 72 79 2e 20 49 66 20 74 | necessa|ry. If t|
|00001db0| 68 65 20 66 75 6e 63 74 | 69 6f 6e 0d 20 20 20 64 |he funct|ion. d|
|00001dc0| 6f 63 75 6d 65 6e 74 61 | 74 69 6f 6e 20 64 6f 65 |ocumenta|tion doe|
|00001dd0| 73 20 6e 6f 74 20 63 6c | 65 61 72 6c 79 20 73 74 |s not cl|early st|
|00001de0| 61 74 65 20 74 68 61 74 | 20 74 68 65 20 61 72 67 |ate that| the arg|
|00001df0| 75 6d 65 6e 74 73 20 77 | 69 6c 6c 20 62 65 0d 20 |uments w|ill be. |
|00001e00| 20 20 6d 6f 64 69 66 69 | 65 64 20 64 75 72 69 6e | modifi|ed durin|
|00001e10| 67 20 66 75 6e 63 74 69 | 6f 6e 20 65 78 65 63 75 |g functi|on execu|
|00001e20| 74 69 6f 6e 2c 20 63 61 | 72 65 20 73 68 6f 75 6c |tion, ca|re shoul|
|00001e30| 64 20 62 65 20 65 78 65 | 72 63 69 73 65 64 20 74 |d be exe|rcised t|
|00001e40| 6f 0d 20 20 20 61 76 6f | 69 64 20 63 68 61 6e 67 |o. avo|id chang|
|00001e50| 69 6e 67 20 61 6e 79 20 | 6f 66 20 74 68 65 20 66 |ing any |of the f|
|00001e60| 75 6e 63 74 69 6f 6e 20 | 61 72 67 75 6d 65 6e 74 |unction |argument|
|00001e70| 73 2e 20 49 66 20 6e 65 | 63 65 73 73 61 72 79 2c |s. If ne|cessary,|
|00001e80| 20 74 68 65 0d 20 20 20 | 66 75 6e 63 74 69 6f 6e | the. |function|
|00001e90| 20 61 72 67 75 6d 65 6e | 74 73 20 63 61 6e 20 62 | argumen|ts can b|
|00001ea0| 65 20 63 6f 70 69 65 64 | 20 74 6f 20 6c 6f 63 61 |e copied| to loca|
|00001eb0| 6c 20 76 61 72 69 61 62 | 6c 65 73 2c 20 73 6f 20 |l variab|les, so |
|00001ec0| 74 68 61 74 0d 20 20 20 | 63 68 61 6e 67 65 73 20 |that. |changes |
|00001ed0| 77 69 6c 6c 20 6e 6f 74 | 20 61 66 66 65 63 74 20 |will not| affect |
|00001ee0| 74 68 65 20 63 61 6c 6c | 65 72 27 73 20 76 61 72 |the call|er's var|
|00001ef0| 69 61 62 6c 65 73 2e 0d | 0d 5c 73 75 62 73 65 63 |iables..|.\subsec|
|00001f00| 74 69 6f 6e 7b 46 75 6e | 63 74 69 6f 6e 20 4c 6f |tion{Fun|ction Lo|
|00001f10| 63 61 6c 20 56 61 72 69 | 61 62 6c 65 73 7d 0d 0d |cal Vari|ables}..|
|00001f20| 20 20 20 4c 6f 63 61 6c | 20 76 61 72 69 61 62 6c | Local| variabl|
|00001f30| 65 73 20 61 72 65 20 63 | 72 65 61 74 65 64 20 65 |es are c|reated e|
|00001f40| 61 63 68 20 74 69 6d 65 | 20 74 68 65 20 66 75 6e |ach time| the fun|
|00001f50| 63 74 69 6f 6e 20 69 73 | 20 69 6e 76 6f 6b 65 64 |ction is| invoked|
|00001f60| 2e 20 45 61 63 68 0d 20 | 20 20 6c 6f 63 61 6c 20 |. Each. | local |
|00001f70| 76 61 72 69 61 62 6c 65 | 20 69 73 20 69 6e 69 74 |variable| is init|
|00001f80| 69 61 6c 6c 79 20 5c 76 | 65 72 62 2b 55 4e 44 45 |ially \v|erb+UNDE|
|00001f90| 46 49 4e 45 44 2b 2e 20 | 57 68 65 6e 20 65 78 65 |FINED+. |When exe|
|00001fa0| 63 75 74 69 6f 6e 20 68 | 61 73 0d 20 20 20 6c 65 |cution h|as. le|
|00001fb0| 66 74 20 74 68 65 20 66 | 75 6e 63 74 69 6f 6e 2c |ft the f|unction,|
|00001fc0| 20 74 68 65 20 6c 6f 63 | 61 6c 20 76 61 72 69 61 | the loc|al varia|
|00001fd0| 62 6c 65 73 20 61 72 65 | 20 64 65 73 74 72 6f 79 |bles are| destroy|
|00001fe0| 65 64 2e 0d 0d 20 20 20 | 49 66 20 79 6f 75 20 77 |ed... |If you w|
|00001ff0| 69 73 68 20 74 6f 20 77 | 72 69 74 65 20 66 75 6e |ish to w|rite fun|
|00002000| 63 74 69 6f 6e 28 73 29 | 20 74 6f 20 73 65 72 76 |ction(s)| to serv|
|00002010| 65 20 61 73 20 6f 66 74 | 65 6e 20 75 73 65 64 20 |e as oft|en used |
|00002020| 75 74 69 6c 69 74 69 65 | 73 0d 20 20 20 6f 72 20 |utilitie|s. or |
|00002030| 6c 69 62 72 61 72 69 65 | 73 2c 20 74 68 65 6e 20 |librarie|s, then |
|00002040| 63 61 72 65 20 73 68 6f | 75 6c 64 20 62 65 20 74 |care sho|uld be t|
|00002050| 61 6b 65 6e 20 74 6f 20 | 64 65 63 6c 61 72 65 20 |aken to |declare |
|00002060| 61 6c 6c 20 76 61 72 69 | 61 62 6c 65 73 0d 20 20 |all vari|ables. |
|00002070| 20 28 6f 74 68 65 72 20 | 74 68 61 6e 20 66 75 6e | (other |than fun|
|00002080| 63 74 69 6f 6e 20 61 72 | 67 75 6d 65 6e 74 73 29 |ction ar|guments)|
|00002090| 20 61 73 20 6c 6f 63 61 | 6c 2e 20 44 65 63 6c 61 | as loca|l. Decla|
|000020a0| 72 69 6e 67 20 61 6c 6c | 20 66 75 6e 63 74 69 6f |ring all| functio|
|000020b0| 6e 0d 20 20 20 76 61 72 | 69 61 62 6c 65 73 20 61 |n. var|iables a|
|000020c0| 73 20 6c 6f 63 61 6c 20 | 77 69 6c 6c 20 70 72 65 |s local |will pre|
|000020d0| 76 65 6e 74 20 61 63 63 | 69 64 65 6e 74 61 6c 20 |vent acc|idental |
|000020e0| 64 65 73 74 72 75 63 74 | 69 6f 6e 20 6f 66 20 75 |destruct|ion of u|
|000020f0| 73 65 72 27 73 0d 20 20 | 20 67 6c 6f 62 61 6c 20 |ser's. | global |
|00002100| 76 61 72 69 61 62 6c 65 | 73 2e 0d 0d 5c 73 75 62 |variable|s...\sub|
|00002110| 73 65 63 74 69 6f 6e 7b | 46 75 6e 63 74 69 6f 6e |section{|Function|
|00002120| 20 52 65 63 75 72 73 69 | 6f 6e 7d 0d 0d 20 20 20 | Recursi|on}.. |
|00002130| 46 75 6e 63 74 69 6f 6e | 20 63 61 6e 20 63 61 6c |Function| can cal|
|00002140| 6c 20 74 68 65 6d 73 65 | 6c 76 65 73 20 72 65 63 |l themse|lves rec|
|00002150| 75 72 73 69 76 65 6c 79 | 2e 20 45 61 63 68 20 74 |ursively|. Each t|
|00002160| 69 6d 65 20 65 78 65 63 | 75 74 69 6f 6e 0d 20 20 |ime exec|ution. |
|00002170| 20 70 61 73 73 65 73 20 | 69 6e 74 6f 20 74 68 65 | passes |into the|
|00002180| 20 66 75 6e 63 74 69 6f | 6e 20 74 68 65 20 6c 6f | functio|n the lo|
|00002190| 63 61 6c 20 76 61 72 69 | 61 62 6c 65 73 20 61 72 |cal vari|ables ar|
|000021a0| 65 20 28 72 65 29 63 72 | 65 61 74 65 64 2e 20 54 |e (re)cr|eated. T|
|000021b0| 68 65 72 65 0d 20 20 20 | 69 73 20 61 20 73 70 65 |here. |is a spe|
|000021c0| 63 69 61 6c 20 6b 65 79 | 77 6f 72 64 3a 20 5c 76 |cial key|word: \v|
|000021d0| 65 72 62 2b 24 73 65 6c | 66 2b 2c 20 77 68 69 63 |erb+$sel|f+, whic|
|000021e0| 68 20 63 61 6e 20 62 65 | 20 75 73 65 64 20 74 6f |h can be| used to|
|000021f0| 20 66 6f 72 63 65 20 61 | 0d 20 20 20 66 75 6e 63 | force a|. func|
|00002200| 74 69 6f 6e 20 74 6f 20 | 72 65 66 65 72 20 74 6f |tion to |refer to|
|00002210| 20 69 74 73 65 6c 66 2e | 20 54 68 69 73 20 69 73 | itself.| This is|
|00002220| 20 6f 6e 6c 79 20 6e 65 | 63 65 73 73 61 72 79 20 | only ne|cessary |
|00002230| 69 66 20 79 6f 75 20 70 | 6c 61 6e 20 74 6f 0d 20 |if you p|lan to. |
|00002240| 20 20 72 65 6e 61 6d 65 | 20 74 68 65 20 66 75 6e | rename| the fun|
|00002250| 63 74 69 6f 6e 20 61 66 | 74 65 72 20 69 74 20 68 |ction af|ter it h|
|00002260| 61 73 20 62 65 65 6e 20 | 63 72 65 61 74 65 64 2e |as been |created.|
|00002270| 0d 0d 5c 62 65 67 69 6e | 7b 76 65 72 62 61 74 69 |..\begin|{verbati|
|00002280| 6d 7d 0d 66 61 63 20 3d | 20 66 75 6e 63 74 69 6f |m}.fac =| functio|
|00002290| 6e 20 28 20 61 20 29 20 | 0d 7b 0d 20 20 69 66 28 |n ( a ) |.{. if(|
|000022a0| 61 20 3c 3d 20 31 29 20 | 0d 20 20 7b 0d 20 20 20 |a <= 1) |. {. |
|000022b0| 20 20 20 72 65 74 75 72 | 6e 20 31 3b 0d 20 20 65 | retur|n 1;. e|
|000022c0| 6c 73 65 0d 20 20 20 20 | 20 20 72 65 74 75 72 6e |lse. | return|
|000022d0| 20 61 2a 66 61 63 20 28 | 61 2d 31 29 3b 20 20 20 | a*fac (|a-1); |
|000022e0| 2f 2f 20 72 65 74 75 72 | 6e 20 61 2a 24 73 65 6c |// retur|n a*$sel|
|000022f0| 66 20 28 61 2d 31 29 3b | 0d 20 20 7d 0d 7d 3b 0d |f (a-1);|. }.};.|
|00002300| 5c 65 6e 64 7b 76 65 72 | 62 61 74 69 6d 7d 0d 0d |\end{ver|batim}..|
|00002310| 20 20 20 49 6e 20 74 68 | 65 20 70 72 65 76 69 6f | In th|e previo|
|00002320| 75 73 20 65 78 61 6d 70 | 6c 65 20 61 20 66 61 63 |us examp|le a fac|
|00002330| 74 6f 72 69 61 6c 20 63 | 6f 6d 70 75 74 61 74 69 |torial c|omputati|
|00002340| 6f 6e 20 69 73 20 70 65 | 72 66 6f 72 6d 65 64 20 |on is pe|rformed |
|00002350| 75 73 69 6e 67 0d 20 20 | 20 72 65 63 75 72 73 69 |using. | recursi|
|00002360| 6f 6e 5c 66 6f 6f 74 6e | 6f 74 65 7b 4e 6f 74 20 |on\footn|ote{Not |
|00002370| 6e 65 63 65 73 73 61 72 | 69 6c 79 20 61 6e 20 65 |necessar|ily an e|
|00002380| 66 66 69 63 69 65 6e 74 | 20 77 61 79 20 74 6f 20 |fficient| way to |
|00002390| 63 6f 6d 70 75 74 65 20 | 74 68 65 0d 20 20 20 66 |compute |the. f|
|000023a0| 61 63 74 6f 72 69 61 6c | 7d 2e 20 49 6e 20 74 68 |actorial|}. In th|
|000023b0| 65 20 73 65 63 6f 6e 64 | 20 72 65 74 75 72 6e 20 |e second| return |
|000023c0| 73 74 61 74 65 6d 65 6e | 74 2c 20 74 68 65 20 66 |statemen|t, the f|
|000023d0| 75 6e 63 74 69 6f 6e 20 | 63 61 6c 6c 73 0d 20 20 |unction |calls. |
|000023e0| 20 69 74 73 65 6c 66 20 | 75 6e 74 69 6c 20 24 61 | itself |until $a|
|000023f0| 20 5c 6c 65 71 20 31 24 | 2e 20 49 6e 20 74 68 65 | \leq 1$|. In the|
|00002400| 20 65 76 65 6e 74 20 74 | 68 61 74 20 74 68 65 20 | event t|hat the |
|00002410| 66 75 6e 63 74 69 6f 6e | 20 69 73 20 6c 61 74 65 |function| is late|
|00002420| 72 0d 20 20 20 63 6f 70 | 69 65 64 20 74 6f 20 61 |r. cop|ied to a|
|00002430| 6e 6f 74 68 65 72 20 76 | 61 72 69 61 62 6c 65 2c |nother v|ariable,|
|00002440| 20 61 6e 64 20 74 68 65 | 20 6f 72 69 67 69 6e 61 | and the| origina|
|00002450| 6c 20 64 65 73 74 72 6f | 79 65 64 2c 20 74 68 65 |l destro|yed, the|
|00002460| 0d 20 20 20 66 75 6e 63 | 74 69 6f 6e 20 77 69 6c |. func|tion wil|
|00002470| 6c 20 6e 6f 20 6c 6f 6e | 67 65 72 20 77 6f 72 6b |l no lon|ger work|
|00002480| 2e 20 54 6f 20 61 76 6f | 69 64 20 74 68 69 73 2c |. To avo|id this,|
|00002490| 20 75 73 65 20 74 68 65 | 20 73 70 65 63 69 61 6c | use the| special|
|000024a0| 0d 20 20 20 6b 65 79 77 | 6f 72 64 20 5c 76 65 72 |. keyw|ord \ver|
|000024b0| 62 2b 24 73 65 6c 66 2b | 20 69 6e 20 70 6c 61 63 |b+$self+| in plac|
|000024c0| 65 20 6f 66 20 74 68 65 | 20 66 75 6e 63 74 69 6f |e of the| functio|
|000024d0| 6e 20 73 65 6c 66 2d 72 | 65 66 65 72 65 6e 63 65 |n self-r|eference|
|000024e0| 2e 0d 0d 5c 73 65 63 74 | 69 6f 6e 7b 45 78 61 6d |...\sect|ion{Exam|
|000024f0| 70 6c 65 73 7d 0d 0d 20 | 20 20 4d 61 6e 79 20 66 |ples}.. | Many f|
|00002500| 75 6e 63 74 69 6f 6e 73 | 20 61 72 65 20 69 6e 63 |unctions| are inc|
|00002510| 6c 75 64 65 64 20 77 69 | 74 68 20 74 68 65 20 5c |luded wi|th the \|
|00002520| 52 4c 61 42 5c 20 73 6f | 75 72 63 65 20 64 69 73 |RLaB\ so|urce dis|
|00002530| 74 72 69 62 75 74 69 6f | 6e 2e 0d 20 20 20 46 75 |tributio|n.. Fu|
|00002540| 6e 63 74 69 6f 6e 73 20 | 63 61 6e 20 62 65 20 66 |nctions |can be f|
|00002550| 6f 75 6e 64 20 69 6e 20 | 74 68 65 20 64 69 73 74 |ound in |the dist|
|00002560| 72 69 62 75 74 69 6f 6e | 20 73 75 62 64 69 72 65 |ribution| subdire|
|00002570| 63 74 6f 72 69 65 73 0d | 20 20 20 5c 76 65 72 62 |ctories.| \verb|
|00002580| 2b 2e 2f 72 6c 69 62 2b | 2c 20 5c 76 65 72 62 2b |+./rlib+|, \verb+|
|00002590| 2e 2f 74 6f 6f 6c 62 6f | 78 2b 2c 20 61 6e 64 20 |./toolbo|x+, and |
|000025a0| 5c 76 65 72 62 2b 2e 2f | 63 6f 6e 74 72 69 62 2b |\verb+./|contrib+|
|000025b0| 2e 0d 0d 20 20 20 57 65 | 20 77 69 6c 6c 20 64 69 |... We| will di|
|000025c0| 73 63 75 73 73 20 61 20 | 66 65 77 20 65 78 61 6d |scuss a |few exam|
|000025d0| 70 6c 65 73 20 66 72 6f | 6d 20 74 68 65 20 5c 52 |ples fro|m the \R|
|000025e0| 4c 61 42 5c 20 73 6f 75 | 72 63 65 20 64 69 73 74 |LaB\ sou|rce dist|
|000025f0| 72 69 62 75 74 69 6f 6e | 2e 0d 20 20 20 0d 5c 73 |ribution|.. .\s|
|00002600| 75 62 73 65 63 74 69 6f | 6e 7b 4d 65 61 6e 20 45 |ubsectio|n{Mean E|
|00002610| 78 61 6d 70 6c 65 7d 0d | 0d 5c 62 65 67 69 6e 7b |xample}.|.\begin{|
|00002620| 66 69 67 75 72 65 7d 0d | 5c 62 65 67 69 6e 7b 76 |figure}.|\begin{v|
|00002630| 65 72 62 61 74 69 6d 7d | 0d 2f 2f 2d 2d 2d 2d 2d |erbatim}|.//-----|
|00002640| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00002650| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00002660| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00002670| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2f 2f |--------|------//|
|00002680| 0d 2f 2f 0d 2f 2f 20 20 | 53 79 6e 74 61 78 3a 20 |.//.// |Syntax: |
|00002690| 20 20 20 20 6d 65 61 6e | 20 28 20 41 20 29 0d 0d | mean| ( A )..|
|000026a0| 2f 2f 20 20 44 65 73 63 | 72 69 70 74 69 6f 6e 3a |// Desc|ription:|
|000026b0| 0d 0d 2f 2f 20 20 43 61 | 6c 63 75 6c 61 74 65 20 |..// Ca|lculate |
|000026c0| 74 68 65 20 6d 65 61 6e | 20 76 61 6c 75 65 2e 20 |the mean| value. |
|000026d0| 49 66 20 74 68 65 20 69 | 6e 70 75 74 20 69 73 20 |If the i|nput is |
|000026e0| 61 20 31 78 4e 2c 20 74 | 68 65 6e 20 63 6f 6d 70 |a 1xN, t|hen comp|
|000026f0| 75 74 65 20 74 68 65 0d | 2f 2f 20 20 6d 65 61 6e |ute the.|// mean|
|00002700| 20 76 61 6c 75 65 20 6f | 66 20 61 6c 6c 20 74 68 | value o|f all th|
|00002710| 65 20 65 6c 65 6d 65 6e | 74 73 2e 20 0d 0d 2f 2f |e elemen|ts. ..//|
|00002720| 20 20 49 66 20 74 68 65 | 20 69 6e 70 75 74 20 69 | If the| input i|
|00002730| 73 20 61 20 4d 78 4e 20 | 6d 61 74 72 69 78 20 74 |s a MxN |matrix t|
|00002740| 68 65 20 63 6f 6d 70 75 | 74 65 20 61 20 72 6f 77 |he compu|te a row|
|00002750| 20 6d 61 74 72 69 78 20 | 6f 66 20 74 68 65 20 6d | matrix |of the m|
|00002760| 65 61 6e 0d 2f 2f 20 20 | 76 61 6c 75 65 20 6f 66 |ean.// |value of|
|00002770| 20 65 61 63 68 20 63 6f | 6c 75 6d 6e 20 6f 66 20 | each co|lumn of |
|00002780| 74 68 65 20 69 6e 70 75 | 74 2e 20 0d 2f 2f 0d 2f |the inpu|t. .//./|
|00002790| 2f 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |/-------|--------|
|000027a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000027b0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000027c0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000027d0| 2d 2d 2d 2d 2f 2f 0d 0d | 6d 65 61 6e 20 3d 20 66 |----//..|mean = f|
|000027e0| 75 6e 63 74 69 6f 6e 28 | 78 29 0d 7b 0d 20 20 6c |unction(|x).{. l|
|000027f0| 6f 63 61 6c 28 6d 29 3b | 0d 0d 20 20 6d 20 3d 20 |ocal(m);|.. m = |
|00002800| 73 69 7a 65 20 28 78 29 | 5b 31 5d 3b 0d 20 20 69 |size (x)|[1];. i|
|00002810| 66 28 20 6d 20 3d 3d 20 | 31 20 29 20 0d 20 20 7b |f( m == |1 ) . {|
|00002820| 20 0d 20 20 20 20 6d 20 | 3d 20 73 69 7a 65 20 28 | . m |= size (|
|00002830| 78 29 5b 32 5d 3b 0d 20 | 20 7d 0d 0d 20 20 72 65 |x)[2];. | }.. re|
|00002840| 74 75 72 6e 20 73 75 6d | 28 20 78 20 29 20 2f 20 |turn sum|( x ) / |
|00002850| 6d 3b 0d 7d 3b 0d 5c 65 | 6e 64 7b 76 65 72 62 61 |m;.};.\e|nd{verba|
|00002860| 74 69 6d 7d 0d 5c 63 61 | 70 74 69 6f 6e 7b 4d 65 |tim}.\ca|ption{Me|
|00002870| 61 6e 20 46 75 6e 63 74 | 69 6f 6e 7d 20 5c 6c 61 |an Funct|ion} \la|
|00002880| 62 65 6c 7b 66 69 67 3a | 6d 65 61 6e 7d 0d 5c 65 |bel{fig:|mean}.\e|
|00002890| 6e 64 7b 66 69 67 75 72 | 65 7d 0d 0d 20 20 20 54 |nd{figur|e}.. T|
|000028a0| 68 65 20 72 66 69 6c 65 | 20 5c 76 65 72 62 2b 6d |he rfile| \verb+m|
|000028b0| 65 61 6e 2e 72 2b 20 28 | 53 65 65 20 46 69 67 75 |ean.r+ (|See Figu|
|000028c0| 72 65 7e 5c 72 65 66 7b | 66 69 67 3a 6d 65 61 6e |re~\ref{|fig:mean|
|000028d0| 7d 29 20 68 61 73 20 73 | 65 76 65 72 61 6c 0d 20 |}) has s|everal. |
|000028e0| 20 20 6e 6f 74 65 77 6f | 72 74 68 79 20 61 74 74 | notewo|rthy att|
|000028f0| 72 69 62 75 74 65 73 2e | 0d 0d 20 20 20 5c 62 65 |ributes.|.. \be|
|00002900| 67 69 6e 7b 65 6e 75 6d | 65 72 61 74 65 7d 0d 20 |gin{enum|erate}. |
|00002910| 20 20 20 20 20 5c 69 74 | 65 6d 20 54 68 65 20 74 | \it|em The t|
|00002920| 6f 70 20 6c 69 6e 65 73 | 20 6f 66 20 74 68 65 20 |op lines| of the |
|00002930| 66 69 6c 65 20 63 6f 6e | 74 61 69 6e 20 63 6f 6d |file con|tain com|
|00002940| 6d 65 6e 74 73 20 77 68 | 69 63 68 20 64 6f 63 75 |ments wh|ich docu|
|00002950| 6d 65 6e 74 0d 20 20 20 | 20 20 20 20 20 20 20 20 |ment. | |
|00002960| 20 74 68 65 20 75 73 61 | 67 65 20 6f 66 20 74 68 | the usa|ge of th|
|00002970| 65 20 66 75 6e 63 74 69 | 6f 6e 2e 20 54 68 69 73 |e functi|on. This|
|00002980| 20 69 73 20 75 73 65 66 | 75 6c 2c 20 73 69 6e 63 | is usef|ul, sinc|
|00002990| 65 20 74 68 65 20 74 68 | 65 0d 20 20 20 20 20 20 |e the th|e. |
|000029a0| 20 20 20 20 20 20 72 6c | 61 62 20 68 65 6c 70 20 | rl|ab help |
|000029b0| 66 75 6e 63 74 69 6f 6e | 20 77 69 6c 6c 20 63 6f |function| will co|
|000029c0| 70 79 20 74 68 65 20 63 | 6f 6e 74 65 6e 74 73 20 |py the c|ontents |
|000029d0| 6f 66 20 65 61 63 68 20 | 72 66 69 6c 65 20 74 6f |of each |rfile to|
|000029e0| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 74 68 65 |. | the|
|000029f0| 20 73 63 72 65 65 6e 2e | 20 49 66 20 64 6f 63 75 | screen.| If docu|
|00002a00| 6d 65 6e 74 61 74 69 6f | 6e 20 63 6f 6d 6d 65 6e |mentatio|n commen|
|00002a10| 74 73 20 61 72 65 20 69 | 6e 63 6c 75 64 65 20 69 |ts are i|nclude i|
|00002a20| 6e 20 74 68 65 0d 20 20 | 20 20 20 20 20 20 20 20 |n the. | |
|00002a30| 20 20 74 6f 70 6d 6f 73 | 74 20 70 6f 72 74 69 6f | topmos|t portio|
|00002a40| 6e 20 6f 66 20 74 68 65 | 20 66 69 6c 65 2c 20 74 |n of the| file, t|
|00002a50| 68 65 6e 20 75 73 65 72 | 73 20 77 69 6c 6c 20 68 |hen user|s will h|
|00002a60| 61 76 65 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |ave. | |
|00002a70| 63 6f 6e 76 65 6e 69 65 | 6e 74 20 61 63 63 65 73 |convenie|nt acces|
|00002a80| 73 20 74 6f 20 74 68 65 | 20 68 65 6c 70 20 63 6f |s to the| help co|
|00002a90| 6d 6d 65 6e 74 73 2e 0d | 0d 20 20 20 20 20 20 5c |mments..|. \|
|00002aa0| 69 74 65 6d 20 5c 76 65 | 72 62 2b 6d 65 61 6e 2b |item \ve|rb+mean+|
|00002ab0| 20 64 6f 65 73 20 6e 6f | 74 20 64 6f 20 61 6e 79 | does no|t do any|
|00002ac0| 20 65 72 72 6f 72 20 63 | 68 65 63 6b 69 6e 67 20 | error c|hecking |
|00002ad0| 6f 6e 20 74 68 65 20 69 | 6e 70 75 74 0d 20 20 20 |on the i|nput. |
|00002ae0| 20 20 20 20 20 20 20 20 | 20 61 72 67 75 6d 65 6e | | argumen|
|00002af0| 74 73 2e 20 57 68 65 74 | 68 65 72 20 69 74 20 73 |ts. Whet|her it s|
|00002b00| 68 6f 75 6c 64 20 6f 72 | 20 6e 6f 74 20 69 73 20 |hould or| not is |
|00002b10| 64 65 62 61 74 61 62 6c | 65 2e 20 57 65 20 77 69 |debatabl|e. We wi|
|00002b20| 6c 6c 0d 20 20 20 20 20 | 20 20 20 20 20 20 20 70 |ll. | p|
|00002b30| 72 65 73 65 6e 74 20 61 | 72 67 75 6d 65 6e 74 73 |resent a|rguments|
|00002b40| 20 66 6f 72 20 61 6e 64 | 20 61 67 61 69 6e 73 74 | for and| against|
|00002b50| 3a 0d 0d 20 20 20 20 20 | 20 20 20 20 5c 62 65 67 |:.. | \beg|
|00002b60| 69 6e 7b 64 65 73 63 72 | 69 70 74 69 6f 6e 7d 0d |in{descr|iption}.|
|00002b70| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 69 74 65 | | \ite|
|00002b80| 6d 5b 46 6f 72 3a 5d 20 | 43 61 6c 6c 69 6e 67 20 |m[For:] |Calling |
|00002b90| 5c 76 65 72 62 2b 6d 65 | 61 6e 2b 20 77 69 74 68 |\verb+me|an+ with|
|00002ba0| 20 61 20 73 74 72 69 6e | 67 2c 20 6f 72 20 61 20 | a strin|g, or a |
|00002bb0| 6c 69 73 74 0d 20 20 20 | 20 20 20 20 20 20 20 20 |list. | |
|00002bc0| 20 76 61 72 69 61 62 6c | 65 20 61 73 20 61 72 67 | variabl|e as arg|
|00002bd0| 75 6d 65 6e 74 20 77 69 | 6c 6c 20 72 65 73 75 6c |ument wi|ll resul|
|00002be0| 74 20 69 6e 20 61 20 73 | 6c 69 67 68 74 6c 79 20 |t in a s|lightly |
|00002bf0| 6f 62 73 63 75 72 65 0d | 20 20 20 20 20 20 20 20 |obscure.| |
|00002c00| 20 20 20 20 65 72 72 6f | 72 20 6d 65 73 73 61 67 | erro|r messag|
|00002c10| 65 2e 0d 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |e... | |
|00002c20| 5c 62 65 67 69 6e 7b 76 | 65 72 62 61 74 69 6d 7d |\begin{v|erbatim}|
|00002c30| 0d 3e 20 6d 65 61 6e 20 | 28 20 22 73 74 72 69 6e |.> mean |( "strin|
|00002c40| 67 20 63 6f 6e 73 74 61 | 6e 74 22 20 29 0d 72 6c |g consta|nt" ).rl|
|00002c50| 61 62 3a 20 4e 55 4c 4c | 2c 20 69 6e 76 61 6c 69 |ab: NULL|, invali|
|00002c60| 64 20 74 79 70 65 20 66 | 6f 72 20 73 75 6d 28 29 |d type f|or sum()|
|00002c70| 0d 6e 65 61 72 20 6c 69 | 6e 65 20 32 35 2c 20 66 |.near li|ne 25, f|
|00002c80| 69 6c 65 3a 20 2f 75 73 | 72 2f 6c 6f 63 61 6c 2f |ile: /us|r/local/|
|00002c90| 6c 69 62 2f 72 6c 61 62 | 2f 72 6c 69 62 2f 6d 65 |lib/rlab|/rlib/me|
|00002ca0| 61 6e 2e 72 0d 3e 20 6d | 65 61 6e 20 28 20 3c 3c |an.r.> m|ean ( <<|
|00002cb0| 20 5b 31 2c 32 2c 33 5d | 3b 20 31 30 30 20 3e 3e | [1,2,3]|; 100 >>|
|00002cc0| 20 29 0d 72 6c 61 62 3a | 20 4e 55 4c 4c 2c 20 69 | ).rlab:| NULL, i|
|00002cd0| 6e 76 61 6c 69 64 20 74 | 79 70 65 20 66 6f 72 20 |nvalid t|ype for |
|00002ce0| 73 75 6d 28 29 0d 6e 65 | 61 72 20 6c 69 6e 65 20 |sum().ne|ar line |
|00002cf0| 32 35 2c 20 66 69 6c 65 | 3a 20 2f 75 73 72 2f 6c |25, file|: /usr/l|
|00002d00| 6f 63 61 6c 2f 6c 69 62 | 2f 72 6c 61 62 2f 72 6c |ocal/lib|/rlab/rl|
|00002d10| 69 62 2f 6d 65 61 6e 2e | 72 0d 3e 20 20 20 20 20 |ib/mean.|r.> |
|00002d20| 20 20 20 20 20 20 20 20 | 5c 65 6e 64 7b 76 65 72 | |\end{ver|
|00002d30| 62 61 74 69 6d 7d 0d 0d | 20 20 20 20 20 20 20 20 |batim}..| |
|00002d40| 20 20 20 20 49 6e 73 74 | 65 61 64 20 6f 66 20 5c | Inst|ead of \|
|00002d50| 76 65 72 62 2b 6d 65 61 | 6e 2b 20 72 65 70 6f 72 |verb+mea|n+ repor|
|00002d60| 74 69 6e 67 20 74 68 65 | 20 65 72 72 6f 72 2c 20 |ting the| error, |
|00002d70| 74 68 65 20 65 72 72 6f | 72 20 69 73 0d 20 20 20 |the erro|r is. |
|00002d80| 20 20 20 20 20 20 20 20 | 20 70 72 6f 70 61 67 61 | | propaga|
|00002d90| 74 65 64 20 64 6f 77 6e | 20 74 6f 20 5c 76 65 72 |ted down| to \ver|
|00002da0| 62 2b 73 75 6d 2b 2e 20 | 54 68 69 73 20 69 73 20 |b+sum+. |This is |
|00002db0| 73 6f 6d 65 77 68 61 74 | 20 63 6f 6e 66 75 73 69 |somewhat| confusi|
|00002dc0| 6e 67 2c 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |ng,. | |
|00002dd0| 73 69 6e 63 65 20 74 68 | 65 20 75 73 65 72 20 63 |since th|e user c|
|00002de0| 6f 6d 6d 69 74 74 65 64 | 20 74 68 65 20 65 72 72 |ommitted| the err|
|00002df0| 6f 72 20 77 69 74 68 20 | 74 68 65 20 66 75 6e 63 |or with |the func|
|00002e00| 74 69 6f 6e 0d 20 20 20 | 20 20 20 20 20 20 20 20 |tion. | |
|00002e10| 20 5c 76 65 72 62 2b 6d | 65 61 6e 2b 2e 20 0d 0d | \verb+m|ean+. ..|
|00002e20| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 69 74 65 | | \ite|
|00002e30| 6d 5b 41 67 61 69 6e 73 | 74 3a 5d 20 54 68 65 20 |m[Agains|t:] The |
|00002e40| 66 75 6e 63 74 69 6f 6e | 20 69 73 20 6f 62 76 69 |function| is obvi|
|00002e50| 6f 75 73 6c 79 20 69 6e | 74 65 6e 64 65 64 20 74 |ously in|tended t|
|00002e60| 6f 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 63 61 |o. | ca|
|00002e70| 6c 63 75 6c 61 74 65 20 | 74 68 65 20 6d 65 61 6e |lculate |the mean|
|00002e80| 20 76 61 6c 75 65 20 6f | 66 20 61 20 76 65 63 74 | value o|f a vect|
|00002e90| 6f 72 2c 20 6f 72 20 6d | 61 74 72 69 78 20 6f 62 |or, or m|atrix ob|
|00002ea0| 6a 65 63 74 2e 0d 20 20 | 20 20 20 20 20 20 20 20 |ject.. | |
|00002eb0| 20 20 41 6e 64 2c 20 66 | 6f 72 20 61 6e 79 20 6e | And, f|or any n|
|00002ec0| 75 6d 65 72 69 63 20 61 | 72 67 75 6d 65 6e 74 20 |umeric a|rgument |
|00002ed0| 5c 76 65 72 62 2b 6d 65 | 61 6e 2b 20 77 69 6c 6c |\verb+me|an+ will|
|00002ee0| 20 77 6f 72 6b 20 6a 75 | 73 74 0d 20 20 20 20 20 | work ju|st. |
|00002ef0| 20 20 20 20 20 20 20 66 | 69 6e 65 2e 20 55 73 65 | f|ine. Use|
|00002f00| 72 73 20 77 68 6f 20 61 | 72 65 20 66 6f 6f 6c 69 |rs who a|re fooli|
|00002f10| 73 68 20 65 6e 6f 75 67 | 68 20 74 6f 20 74 72 79 |sh enoug|h to try|
|00002f20| 20 61 6e 64 20 63 6f 6d | 70 75 74 65 20 74 68 65 | and com|pute the|
|00002f30| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 6d 65 61 |. | mea|
|00002f40| 6e 20 76 61 6c 75 65 20 | 6f 66 20 61 20 73 74 72 |n value |of a str|
|00002f50| 69 6e 67 2c 20 6f 72 20 | 61 20 68 65 74 65 72 6f |ing, or |a hetero|
|00002f60| 67 65 6e 65 6f 75 73 20 | 6f 62 6a 65 63 74 20 28 |geneous |object (|
|00002f70| 61 20 6c 69 73 74 29 0d | 20 20 20 20 20 20 20 20 |a list).| |
|00002f80| 20 20 20 20 73 68 6f 75 | 6c 64 20 6e 6f 74 20 62 | shou|ld not b|
|00002f90| 65 20 63 61 74 65 72 65 | 64 20 74 6f 2e 20 54 68 |e catere|d to. Th|
|00002fa0| 61 74 20 69 73 2c 20 75 | 73 65 72 73 20 77 68 6f |at is, u|sers who|
|00002fb0| 20 75 73 65 20 74 68 65 | 0d 20 20 20 20 20 20 20 | use the|. |
|00002fc0| 20 20 20 20 20 66 75 6e | 63 74 69 6f 6e 20 63 6f | fun|ction co|
|00002fd0| 72 72 65 63 74 6c 79 2c | 20 73 68 6f 75 6c 64 20 |rrectly,| should |
|00002fe0| 6e 6f 74 20 68 61 76 65 | 20 74 6f 20 70 61 79 20 |not have| to pay |
|00002ff0| 61 20 70 65 72 66 6f 72 | 6d 61 6e 63 65 0d 20 20 |a perfor|mance. |
|00003000| 20 20 20 20 20 20 20 20 | 20 20 70 65 6e 61 6c 74 | | penalt|
|00003010| 79 2e 0d 20 20 20 20 20 | 20 20 20 20 5c 65 6e 64 |y.. | \end|
|00003020| 7b 64 65 73 63 72 69 70 | 74 69 6f 6e 7d 0d 20 20 |{descrip|tion}. |
|00003030| 20 5c 65 6e 64 7b 65 6e | 75 6d 65 72 61 74 65 7d | \end{en|umerate}|
|00003040| 0d 20 20 20 0d 5c 73 75 | 62 73 65 63 74 69 6f 6e |. .\su|bsection|
|00003050| 7b 4d 47 53 20 45 78 61 | 6d 70 6c 65 7d 0d 0d 5c |{MGS Exa|mple}..\|
|00003060| 62 65 67 69 6e 7b 66 69 | 67 75 72 65 7d 0d 5c 62 |begin{fi|gure}.\b|
|00003070| 65 67 69 6e 7b 76 65 72 | 62 61 74 69 6d 7d 0d 2f |egin{ver|batim}./|
|00003080| 2f 0d 2f 2f 20 4d 6f 64 | 69 66 69 65 64 20 47 72 |/.// Mod|ified Gr|
|00003090| 61 6d 2d 53 63 68 6d 69 | 64 74 0d 2f 2f 20 47 69 |am-Schmi|dt.// Gi|
|000030a0| 76 65 6e 20 41 20 28 4d | 78 4e 29 2c 20 77 69 74 |ven A (M|xN), wit|
|000030b0| 68 20 72 61 6e 6b 28 41 | 29 20 3d 20 4e 2e 20 54 |h rank(A|) = N. T|
|000030c0| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 61 6c 67 |he follo|wing alg|
|000030d0| 6f 72 69 74 68 6d 20 63 | 6f 6d 70 75 74 65 73 0d |orithm c|omputes.|
|000030e0| 2f 2f 20 74 68 65 20 66 | 61 63 74 6f 72 69 7a 61 |// the f|actoriza|
|000030f0| 74 69 6f 6e 20 41 20 3d | 20 51 2a 52 20 28 73 6b |tion A =| Q*R (sk|
|00003100| 69 6e 6e 79 20 51 52 29 | 20 77 68 65 72 65 20 51 |inny QR)| where Q|
|00003110| 20 28 4d 78 4e 29 20 68 | 61 73 20 6f 72 74 68 6f | (MxN) h|as ortho|
|00003120| 6e 6f 72 6d 61 6c 0d 2f | 2f 20 63 6f 6c 75 6d 6e |normal./|/ column|
|00003130| 73 20 61 6e 64 20 52 20 | 28 4e 78 4e 29 20 69 73 |s and R |(NxN) is|
|00003140| 20 75 70 70 65 72 20 74 | 72 69 61 6e 67 75 6c 61 | upper t|riangula|
|00003150| 72 0d 2f 2f 0d 2f 2f 20 | 46 72 6f 6d 20 4d 41 54 |r.//.// |From MAT|
|00003160| 52 49 58 20 43 6f 6d 70 | 75 74 61 74 69 6f 6e 73 |RIX Comp|utations|
|00003170| 2c 20 47 2e 48 2e 20 47 | 6f 6c 75 62 2c 20 43 2e |, G.H. G|olub, C.|
|00003180| 46 2e 20 56 61 6e 20 4c | 6f 61 6e 20 28 70 61 67 |F. Van L|oan (pag|
|00003190| 65 20 32 31 39 29 0d 2f | 2f 20 0d 0d 6d 67 73 20 |e 219)./|/ ..mgs |
|000031a0| 3d 20 66 75 6e 63 74 69 | 6f 6e 28 41 29 0d 7b 0d |= functi|on(A).{.|
|000031b0| 20 20 6c 6f 63 61 6c 28 | 61 2c 6b 2c 6a 2c 6e 2c | local(|a,k,j,n,|
|000031c0| 6d 2c 71 2c 72 29 3b 0d | 0d 20 20 61 20 3d 20 41 |m,q,r);.|. a = A|
|000031d0| 3b 0d 20 20 6d 20 3d 20 | 61 2e 6e 72 3b 0d 20 20 |;. m = |a.nr;. |
|000031e0| 6e 20 3d 20 61 2e 6e 63 | 3b 0d 20 20 66 6f 72 28 |n = a.nc|;. for(|
|000031f0| 6b 20 69 6e 20 31 3a 6e | 29 0d 20 20 7b 0d 20 20 |k in 1:n|). {. |
|00003200| 20 20 72 5b 6b 3b 6b 5d | 20 3d 20 6e 6f 72 6d 28 | r[k;k]| = norm(|
|00003210| 20 61 5b 31 3a 6d 3b 6b | 5d 2c 20 22 32 22 29 3b | a[1:m;k|], "2");|
|00003220| 0d 20 20 20 20 71 5b 31 | 3a 6d 3b 6b 5d 20 3d 20 |. q[1|:m;k] = |
|00003230| 61 5b 31 3a 6d 3b 6b 5d | 2f 72 5b 6b 3b 6b 5d 3b |a[1:m;k]|/r[k;k];|
|00003240| 0d 20 20 20 20 66 6f 72 | 28 6a 20 69 6e 20 6b 2b |. for|(j in k+|
|00003250| 31 3a 6e 29 0d 20 20 20 | 20 7b 0d 20 20 20 20 20 |1:n). | {. |
|00003260| 20 72 5b 6b 3b 6a 5d 20 | 3d 20 71 5b 31 3a 6d 3b | r[k;j] |= q[1:m;|
|00003270| 6b 5d 27 20 2a 20 61 5b | 31 3a 6d 3b 6a 5d 3b 0d |k]' * a[|1:m;j];.|
|00003280| 20 20 20 20 20 20 61 5b | 31 3a 6d 3b 6a 5d 20 3d | a[|1:m;j] =|
|00003290| 20 61 5b 31 3a 6d 3b 6a | 5d 20 2d 20 71 5b 31 3a | a[1:m;j|] - q[1:|
|000032a0| 6d 3b 6b 5d 20 2a 20 72 | 5b 6b 3b 6a 5d 3b 0d 20 |m;k] * r|[k;j];. |
|000032b0| 20 20 20 7d 0d 20 20 20 | 7d 0d 20 20 72 65 74 75 | }. |}. retu|
|000032c0| 72 6e 20 3c 3c 20 71 20 | 3d 20 71 3b 20 72 20 3d |rn << q |= q; r =|
|000032d0| 20 72 20 3e 3e 3b 0d 7d | 3b 0d 5c 65 6e 64 7b 76 | r >>;.}|;.\end{v|
|000032e0| 65 72 62 61 74 69 6d 7d | 0d 5c 63 61 70 74 69 6f |erbatim}|.\captio|
|000032f0| 6e 7b 4d 6f 64 69 66 69 | 65 64 20 47 72 61 6d 2d |n{Modifi|ed Gram-|
|00003300| 53 63 68 6d 69 64 74 20 | 46 75 6e 63 74 69 6f 6e |Schmidt |Function|
|00003310| 7d 20 5c 6c 61 62 65 6c | 7b 66 69 67 3a 6d 67 73 |} \label|{fig:mgs|
|00003320| 7d 0d 5c 65 6e 64 7b 66 | 69 67 75 72 65 7d 0d 0d |}.\end{f|igure}..|
|00003330| 20 20 20 54 68 69 73 20 | 65 78 61 6d 70 6c 65 20 | This |example |
|00003340| 28 53 65 65 20 46 69 67 | 75 72 65 7e 5c 72 65 66 |(See Fig|ure~\ref|
|00003350| 7b 66 69 67 3a 6d 67 73 | 7d 29 20 69 6d 70 6c 65 |{fig:mgs|}) imple|
|00003360| 6d 65 6e 74 73 20 61 20 | 6d 6f 64 69 66 69 65 64 |ments a |modified|
|00003370| 0d 20 20 20 47 72 61 6d | 2d 53 63 68 6d 69 64 74 |. Gram|-Schmidt|
|00003380| 20 61 6c 67 6f 72 69 74 | 68 6d 20 74 6f 20 66 69 | algorit|hm to fi|
|00003390| 6e 64 20 61 6e 20 6f 72 | 74 68 6f 6e 6f 72 6d 61 |nd an or|thonorma|
|000033a0| 6c 20 62 61 73 69 73 20 | 66 6f 72 20 74 68 65 20 |l basis |for the |
|000033b0| 69 6e 70 75 74 0d 20 20 | 20 6d 61 74 72 69 78 2e |input. | matrix.|
|000033c0| 20 54 68 65 72 65 20 61 | 72 65 20 73 65 76 65 72 | There a|re sever|
|000033d0| 61 6c 20 69 6d 70 6f 72 | 74 61 6e 74 20 70 6f 69 |al impor|tant poi|
|000033e0| 6e 74 73 20 74 6f 20 72 | 65 63 6f 67 6e 69 7a 65 |nts to r|ecognize|
|000033f0| 20 69 6e 20 74 68 69 73 | 0d 20 20 20 66 75 6e 63 | in this|. func|
|00003400| 74 69 6f 6e 2e 0d 0d 20 | 20 20 5c 62 65 67 69 6e |tion... | \begin|
|00003410| 7b 65 6e 75 6d 65 72 61 | 74 65 7d 0d 20 20 20 20 |{enumera|te}. |
|00003420| 20 20 5c 69 74 65 6d 20 | 54 68 65 20 66 75 6e 63 | \item |The func|
|00003430| 74 69 6f 6e 20 72 65 74 | 75 72 6e 73 20 61 20 6c |tion ret|urns a l|
|00003440| 69 73 74 2e 20 5c 76 65 | 72 62 2b 6d 67 73 2b 20 |ist. \ve|rb+mgs+ |
|00003450| 72 65 74 75 72 6e 73 20 | 61 20 6c 69 73 74 0d 20 |returns |a list. |
|00003460| 20 20 20 20 20 20 20 20 | 20 20 20 63 6f 6e 74 61 | | conta|
|00003470| 69 6e 69 6e 67 20 74 68 | 65 20 6d 61 74 72 69 63 |ining th|e matric|
|00003480| 65 73 20 24 51 24 20 61 | 6e 64 20 24 52 24 2e 20 |es $Q$ a|nd $R$. |
|00003490| 54 68 65 20 6d 65 6d 62 | 65 72 73 20 6f 66 20 74 |The memb|ers of t|
|000034a0| 68 65 0d 20 20 20 20 20 | 20 20 20 20 20 20 20 6c |he. | l|
|000034b0| 69 73 74 20 63 61 6e 20 | 62 65 20 61 63 63 65 73 |ist can |be acces|
|000034c0| 73 65 64 20 62 79 3a 0d | 0d 20 20 20 20 20 20 20 |sed by:.|. |
|000034d0| 20 20 20 20 20 5c 62 65 | 67 69 6e 7b 76 65 72 62 | \be|gin{verb|
|000034e0| 61 74 69 6d 7d 0d 3e 20 | 61 61 20 3d 20 72 61 6e |atim}.> |aa = ran|
|000034f0| 64 28 34 2c 34 29 0d 20 | 61 61 20 3d 0d 20 6d 61 |d(4,4). |aa =. ma|
|00003500| 74 72 69 78 20 63 6f 6c | 75 6d 6e 73 20 31 20 74 |trix col|umns 1 t|
|00003510| 68 72 75 20 34 0d 20 20 | 20 20 20 20 30 2e 37 20 |hru 4. | 0.7 |
|00003520| 20 20 20 20 20 20 30 2e | 39 36 20 20 20 20 20 20 | 0.|96 |
|00003530| 30 2e 39 32 34 20 20 20 | 20 20 20 30 2e 31 34 38 |0.924 | 0.148|
|00003540| 20 20 0d 20 20 20 20 20 | 30 2e 39 35 20 20 20 20 | . |0.95 |
|00003550| 20 20 30 2e 39 31 35 20 | 20 20 20 20 30 2e 30 38 | 0.915 | 0.08|
|00003560| 38 32 20 20 20 20 20 20 | 30 2e 38 37 39 20 20 0d |82 |0.879 .|
|00003570| 20 20 20 30 2e 30 39 31 | 38 20 20 20 20 20 20 30 | 0.091|8 0|
|00003580| 2e 34 34 31 20 20 20 20 | 20 20 30 2e 39 30 38 20 |.441 | 0.908 |
|00003590| 20 20 20 30 2e 30 30 35 | 34 33 20 20 0d 20 20 20 | 0.005|43 . |
|000035a0| 20 30 2e 39 30 32 20 20 | 20 20 20 30 2e 30 37 33 | 0.902 | 0.073|
|000035b0| 35 20 20 20 20 20 20 30 | 2e 33 36 32 20 20 20 20 |5 0|.362 |
|000035c0| 20 20 30 2e 32 32 32 20 | 20 0d 3e 20 78 20 3d 20 | 0.222 | .> x = |
|000035d0| 6d 67 73 20 28 61 61 29 | 0d 20 20 20 71 20 20 20 |mgs (aa)|. q |
|000035e0| 20 20 20 20 20 20 20 20 | 20 72 20 20 20 20 20 20 | | r |
|000035f0| 20 20 20 20 20 20 0d 3e | 20 78 2e 71 0d 20 71 20 | .>| x.q. q |
|00003600| 3d 0d 20 6d 61 74 72 69 | 78 20 63 6f 6c 75 6d 6e |=. matri|x column|
|00003610| 73 20 31 20 74 68 72 75 | 20 34 0d 20 20 20 20 20 |s 1 thru| 4. |
|00003620| 30 2e 34 37 20 20 20 20 | 20 20 30 2e 35 31 33 20 |0.47 | 0.513 |
|00003630| 20 20 20 20 20 30 2e 32 | 36 31 20 20 20 20 20 2d | 0.2|61 -|
|00003640| 30 2e 36 36 39 20 20 0d | 20 20 20 20 30 2e 36 33 |0.669 .| 0.63|
|00003650| 38 20 20 20 20 20 20 30 | 2e 32 34 33 20 20 20 20 |8 0|.243 |
|00003660| 20 2d 30 2e 36 31 33 20 | 20 20 20 20 20 30 2e 33 | -0.613 | 0.3|
|00003670| 39 36 20 20 0d 20 20 20 | 30 2e 30 36 31 37 20 20 |96 . |0.0617 |
|00003680| 20 20 20 20 30 2e 34 33 | 36 20 20 20 20 20 20 30 | 0.43|6 0|
|00003690| 2e 36 34 32 20 20 20 20 | 20 20 30 2e 36 32 38 20 |.642 | 0.628 |
|000036a0| 20 0d 20 20 20 20 30 2e | 36 30 36 20 20 20 20 20 | . 0.|606 |
|000036b0| 2d 30 2e 36 39 38 20 20 | 20 20 20 20 30 2e 33 37 |-0.698 | 0.37|
|000036c0| 39 20 20 20 20 20 30 2e | 30 33 37 38 20 20 0d 3e |9 0.|0378 .>|
|000036d0| 20 6d 67 73 20 28 61 61 | 29 2e 71 0d 20 71 20 3d | mgs (aa|).q. q =|
|000036e0| 0d 20 6d 61 74 72 69 78 | 20 63 6f 6c 75 6d 6e 73 |. matrix| columns|
|000036f0| 20 31 20 74 68 72 75 20 | 34 0d 20 20 20 20 20 30 | 1 thru |4. 0|
|00003700| 2e 34 37 20 20 20 20 20 | 20 30 2e 35 31 33 20 20 |.47 | 0.513 |
|00003710| 20 20 20 20 30 2e 32 36 | 31 20 20 20 20 20 2d 30 | 0.26|1 -0|
|00003720| 2e 36 36 39 20 20 0d 20 | 20 20 20 30 2e 36 33 38 |.669 . | 0.638|
|00003730| 20 20 20 20 20 20 30 2e | 32 34 33 20 20 20 20 20 | 0.|243 |
|00003740| 2d 30 2e 36 31 33 20 20 | 20 20 20 20 30 2e 33 39 |-0.613 | 0.39|
|00003750| 36 20 20 0d 20 20 20 30 | 2e 30 36 31 37 20 20 20 |6 . 0|.0617 |
|00003760| 20 20 20 30 2e 34 33 36 | 20 20 20 20 20 20 30 2e | 0.436| 0.|
|00003770| 36 34 32 20 20 20 20 20 | 20 30 2e 36 32 38 20 20 |642 | 0.628 |
|00003780| 0d 20 20 20 20 30 2e 36 | 30 36 20 20 20 20 20 2d |. 0.6|06 -|
|00003790| 30 2e 36 39 38 20 20 20 | 20 20 20 30 2e 33 37 39 |0.698 | 0.379|
|000037a0| 20 20 20 20 20 30 2e 30 | 33 37 38 20 20 0d 20 20 | 0.0|378 . |
|000037b0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 6e 64 7b | | \end{|
|000037c0| 76 65 72 62 61 74 69 6d | 7d 0d 0d 20 20 20 20 20 |verbatim|}.. |
|000037d0| 20 5c 69 74 65 6d 20 54 | 68 65 20 66 75 6e 63 74 | \item T|he funct|
|000037e0| 69 6f 6e 20 61 72 67 75 | 6d 65 6e 74 20 69 73 20 |ion argu|ment is |
|000037f0| 63 6f 70 69 65 64 2e 20 | 54 68 65 20 61 72 67 75 |copied. |The argu|
|00003800| 6d 65 6e 74 20 5c 76 65 | 72 62 2b 41 2b 20 69 73 |ment \ve|rb+A+ is|
|00003810| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 63 6f 70 |. | cop|
|00003820| 69 65 64 20 74 6f 20 74 | 68 65 20 6c 6f 63 61 6c |ied to t|he local|
|00003830| 20 76 61 72 69 61 62 6c | 65 20 5c 76 65 72 62 2b | variabl|e \verb+|
|00003840| 61 2b 20 74 6f 20 61 76 | 6f 69 64 20 64 65 73 74 |a+ to av|oid dest|
|00003850| 72 6f 79 69 6e 67 0d 20 | 20 20 20 20 20 20 20 20 |roying. | |
|00003860| 20 20 20 74 68 65 20 6f | 72 69 67 69 6e 61 6c 20 | the o|riginal |
|00003870| 63 6f 6e 74 65 6e 74 73 | 20 6f 66 20 5c 76 65 72 |contents| of \ver|
|00003880| 62 2b 41 2b 20 28 6f 72 | 20 5c 76 65 72 62 2b 61 |b+A+ (or| \verb+a|
|00003890| 61 2b 20 69 6e 20 74 68 | 65 0d 20 20 20 20 20 20 |a+ in th|e. |
|000038a0| 20 20 20 20 20 20 63 61 | 6c 6c 65 72 73 20 65 6e | ca|llers en|
|000038b0| 76 69 72 6f 6e 6d 65 6e | 74 29 2e 0d 20 20 20 5c |vironmen|t).. \|
|000038c0| 65 6e 64 7b 65 6e 75 6d | 65 72 61 74 65 7d 0d 0d |end{enum|erate}..|
|000038d0| 5c 73 65 63 74 69 6f 6e | 7b 46 69 6c 65 73 7d 0d |\section|{Files}.|
|000038e0| 0d 20 20 20 53 69 6d 70 | 6c 65 20 60 60 6f 6e 65 |. Simp|le ``one|
|000038f0| 2d 6c 69 6e 65 72 27 27 | 20 66 75 6e 63 74 69 6f |-liner''| functio|
|00003900| 6e 73 20 63 61 6e 20 62 | 65 20 74 79 70 65 64 20 |ns can b|e typed |
|00003910| 69 6e 20 61 74 20 74 68 | 65 20 63 6f 6d 6d 61 6e |in at th|e comman|
|00003920| 64 20 6c 69 6e 65 2e 0d | 20 20 20 48 6f 77 65 76 |d line..| Howev|
|00003930| 65 72 2c 20 74 68 65 79 | 20 61 72 65 20 64 65 73 |er, they| are des|
|00003940| 74 72 6f 79 65 64 20 77 | 68 65 6e 20 74 68 65 20 |troyed w|hen the |
|00003950| 5c 52 4c 61 42 5c 20 73 | 65 73 73 69 6f 6e 20 69 |\RLaB\ s|ession i|
|00003960| 73 20 65 6e 64 65 64 2e | 20 57 68 65 6e 0d 20 20 |s ended.| When. |
|00003970| 20 77 72 69 74 69 6e 67 | 20 6c 6f 6e 67 65 72 20 | writing| longer |
|00003980| 66 75 6e 63 74 69 6f 6e | 73 2c 20 6f 72 20 66 75 |function|s, or fu|
|00003990| 6e 63 74 69 6f 6e 73 20 | 74 68 61 74 20 79 6f 75 |nctions |that you|
|000039a0| 20 77 61 6e 74 20 74 6f | 20 73 61 76 65 20 66 6f | want to| save fo|
|000039b0| 72 0d 20 20 20 72 65 70 | 65 61 74 65 64 20 75 73 |r. rep|eated us|
|000039c0| 61 67 65 3b 20 69 74 20 | 69 73 20 63 6f 6e 76 65 |age; it |is conve|
|000039d0| 6e 69 65 6e 74 20 74 6f | 20 63 72 65 61 74 65 20 |nient to| create |
|000039e0| 74 68 65 6d 20 75 73 69 | 6e 67 20 61 20 74 65 78 |them usi|ng a tex|
|000039f0| 74 20 65 64 69 74 6f 72 | 0d 20 20 20 61 6e 64 20 |t editor|. and |
|00003a00| 73 61 76 65 20 74 68 65 | 6d 20 6f 6e 20 64 69 73 |save the|m on dis|
|00003a10| 6b 20 61 73 20 61 6e 20 | 6f 72 64 69 6e 61 72 79 |k as an |ordinary|
|00003a20| 20 41 53 43 49 49 20 74 | 65 78 74 20 66 69 6c 65 | ASCII t|ext file|
|00003a30| 2e 0d 0d 20 20 20 54 68 | 65 20 66 75 6e 63 74 69 |... Th|e functi|
|00003a40| 6f 6e 20 5c 76 65 72 62 | 2b 6c 6f 61 64 2b 20 77 |on \verb|+load+ w|
|00003a50| 69 6c 6c 20 65 78 65 63 | 75 74 65 20 74 68 65 20 |ill exec|ute the |
|00003a60| 72 6c 61 62 20 73 74 61 | 74 65 6d 65 6e 74 73 20 |rlab sta|tements |
|00003a70| 69 6e 20 61 20 66 69 6c | 65 0d 20 20 20 61 73 20 |in a fil|e. as |
|00003a80| 69 66 20 74 68 65 79 20 | 77 65 72 65 20 74 79 70 |if they |were typ|
|00003a90| 65 64 20 61 74 20 74 68 | 65 20 63 6f 6d 6d 61 6e |ed at th|e comman|
|00003aa0| 64 20 6c 69 6e 65 2e 20 | 54 68 65 20 72 6c 61 62 |d line. |The rlab|
|00003ab0| 20 63 6f 6d 6d 61 6e 64 | 0d 20 20 20 5c 76 65 72 | command|. \ver|
|00003ac0| 62 2b 72 66 69 6c 65 2b | 20 73 65 61 72 63 68 65 |b+rfile+| searche|
|00003ad0| 73 20 61 20 73 70 65 63 | 69 66 69 65 64 20 70 61 |s a spec|ified pa|
|00003ae0| 74 68 20 66 6f 72 20 66 | 69 6c 65 73 20 77 69 74 |th for f|iles wit|
|00003af0| 68 20 61 20 60 2e 72 27 | 0d 20 20 20 65 78 74 65 |h a `.r'|. exte|
|00003b00| 6e 73 69 6f 6e 2e 20 57 | 68 65 6e 20 74 68 65 20 |nsion. W|hen the |
|00003b10| 72 66 69 6c 65 20 63 6f | 6d 6d 61 6e 64 20 66 69 |rfile co|mmand fi|
|00003b20| 6e 64 73 20 61 20 66 69 | 6c 65 20 74 68 61 74 20 |nds a fi|le that |
|00003b30| 6d 61 74 63 68 65 73 20 | 69 74 27 73 0d 20 20 20 |matches |it's. |
|00003b40| 61 72 67 75 6d 65 6e 74 | 2c 20 69 74 20 65 78 65 |argument|, it exe|
|00003b50| 63 75 74 65 73 20 74 68 | 65 20 72 6c 61 62 20 73 |cutes th|e rlab s|
|00003b60| 74 61 74 65 6d 65 6e 74 | 73 20 69 6e 20 74 68 65 |tatement|s in the|
|00003b70| 20 66 69 6c 65 20 61 73 | 20 69 66 20 74 68 65 79 | file as| if they|
|00003b80| 0d 20 20 20 77 65 72 65 | 20 74 79 70 65 64 20 61 |. were| typed a|
|00003b90| 74 20 74 68 65 20 63 6f | 6d 6d 61 6e 64 20 6c 69 |t the co|mmand li|
|00003ba0| 6e 65 2e 0d 0d 20 20 20 | 53 74 61 74 65 6d 65 6e |ne... |Statemen|
|00003bb0| 74 73 20 69 6e 20 61 20 | 66 69 6c 65 20 61 72 65 |ts in a |file are|
|00003bc0| 20 65 78 65 63 75 74 65 | 64 20 69 6e 20 74 68 65 | execute|d in the|
|00003bd0| 20 73 61 6d 65 20 6d 61 | 6e 6e 65 72 20 61 73 20 | same ma|nner as |
|00003be0| 74 68 65 79 20 77 6f 75 | 6c 64 0d 20 20 20 62 65 |they wou|ld. be|
|00003bf0| 20 68 61 64 20 74 68 65 | 79 20 62 65 65 6e 20 74 | had the|y been t|
|00003c00| 79 70 65 64 20 69 6e 20 | 69 6e 74 65 72 61 63 74 |yped in |interact|
|00003c10| 69 76 65 6c 79 2c 20 6f | 72 64 69 6e 61 72 79 20 |ively, o|rdinary |
|00003c20| 63 6f 6d 6d 61 6e 64 73 | 20 61 6e 64 0d 20 20 20 |commands| and. |
|00003c30| 6d 75 6c 74 69 70 6c 65 | 20 66 75 6e 63 74 69 6f |multiple| functio|
|00003c40| 6e 73 20 61 72 65 20 4f | 2e 4b 2e 20 49 6e 20 66 |ns are O|.K. In f|
|00003c50| 61 63 74 2c 20 63 6f 6d | 70 6c 65 74 65 20 70 72 |act, com|plete pr|
|00003c60| 6f 67 72 61 6d 73 20 63 | 61 6e 20 62 65 0d 20 20 |ograms c|an be. |
|00003c70| 20 77 72 69 74 74 65 6e | 20 61 6e 64 20 72 75 6e | written| and run|
|00003c80| 20 69 6e 74 65 72 61 63 | 74 69 76 65 6c 79 20 6f | interac|tively o|
|00003c90| 72 20 69 6e 20 62 61 74 | 63 68 20 6d 6f 64 65 2e |r in bat|ch mode.|
|00003ca0| 20 54 6f 20 72 75 6e 20 | 61 20 70 72 6f 67 72 61 | To run |a progra|
|00003cb0| 6d 20 69 6e 0d 20 20 20 | 62 61 74 63 68 20 6d 6f |m in. |batch mo|
|00003cc0| 64 65 20 79 6f 75 20 63 | 61 6e 20 74 72 79 3a 0d |de you c|an try:.|
|00003cd0| 0d 5c 62 65 67 69 6e 7b | 76 65 72 62 61 74 69 6d |.\begin{|verbatim|
|00003ce0| 7d 0d 24 20 72 6c 61 62 | 20 70 72 6f 67 72 61 6d |}.$ rlab| program|
|00003cf0| 2e 72 20 26 0d 5c 65 6e | 64 7b 76 65 72 62 61 74 |.r &.\en|d{verbat|
|00003d00| 69 6d 7d 0d 0d 20 20 20 | 4f 72 20 74 68 65 20 70 |im}.. |Or the p|
|00003d10| 72 6f 67 72 61 6d 20 63 | 6f 75 6c 64 20 63 6f 6e |rogram c|ould con|
|00003d20| 74 61 69 6e 20 5c 76 65 | 72 62 2b 23 21 2f 75 73 |tain \ve|rb+#!/us|
|00003d30| 72 2f 6c 6f 63 61 6c 2f | 62 69 6e 2f 72 6c 61 62 |r/local/|bin/rlab|
|00003d40| 2b 20 6f 6e 20 74 68 65 | 0d 20 20 20 66 69 72 73 |+ on the|. firs|
|00003d50| 74 20 6c 69 6e 65 2e 20 | 54 68 65 6e 2c 20 69 66 |t line. |Then, if|
|00003d60| 20 79 6f 75 72 20 6f 70 | 65 72 61 74 69 6e 67 20 | your op|erating |
|00003d70| 73 79 73 74 65 6d 20 70 | 72 6f 76 69 64 65 73 20 |system p|rovides |
|00003d80| 74 68 65 20 70 72 6f 70 | 65 72 0d 20 20 20 73 75 |the prop|er. su|
|00003d90| 70 70 6f 72 74 2c 20 72 | 6c 61 62 20 63 61 6e 20 |pport, r|lab can |
|00003da0| 65 78 65 63 75 74 65 20 | 79 6f 75 72 20 70 72 6f |execute |your pro|
|00003db0| 67 72 61 6d 2c 20 69 6e | 74 65 72 61 63 74 69 76 |gram, in|teractiv|
|00003dc0| 65 6c 79 2c 20 6f 72 20 | 69 6e 20 74 68 65 0d 20 |ely, or |in the. |
|00003dd0| 20 20 62 61 63 6b 67 72 | 6f 75 6e 64 20 62 79 20 | backgr|ound by |
|00003de0| 73 69 6d 70 6c 79 20 74 | 79 70 69 6e 67 3a 0d 0d |simply t|yping:..|
|00003df0| 5c 62 65 67 69 6e 7b 76 | 65 72 62 61 74 69 6d 7d |\begin{v|erbatim}|
|00003e00| 0d 24 20 63 68 6d 6f 64 | 20 2b 78 20 70 72 6f 67 |.$ chmod| +x prog|
|00003e10| 72 61 6d 2e 72 0d 24 20 | 2e 2f 70 72 6f 67 72 61 |ram.r.$ |./progra|
|00003e20| 6d 2e 72 0d 5c 65 6e 64 | 7b 76 65 72 62 61 74 69 |m.r.\end|{verbati|
|00003e30| 6d 7d 0d 0d 5c 73 75 62 | 73 65 63 74 69 6f 6e 7b |m}..\sub|section{|
|00003e40| 46 69 6c 65 20 53 74 61 | 74 69 63 20 56 61 72 69 |File Sta|tic Vari|
|00003e50| 61 62 6c 65 73 7d 0d 0d | 20 20 20 41 6c 74 68 6f |ables}..| Altho|
|00003e60| 75 67 68 20 73 74 61 74 | 69 63 20 76 61 72 69 61 |ugh stat|ic varia|
|00003e70| 62 6c 65 73 20 61 72 65 | 20 6e 6f 74 20 70 65 63 |bles are| not pec|
|00003e80| 75 6c 69 61 72 20 74 6f | 20 66 75 6e 63 74 69 6f |uliar to| functio|
|00003e90| 6e 73 2c 20 74 68 65 79 | 20 61 72 65 0d 20 20 20 |ns, they| are. |
|00003ea0| 64 69 73 63 75 73 73 65 | 64 20 68 65 72 65 20 62 |discusse|d here b|
|00003eb0| 65 63 61 75 73 65 20 74 | 68 65 79 20 61 72 65 20 |ecause t|hey are |
|00003ec0| 69 6d 70 6f 72 74 61 6e | 74 20 77 68 65 6e 20 77 |importan|t when w|
|00003ed0| 72 69 74 69 6e 67 20 70 | 61 63 6b 61 67 65 73 2e |riting p|ackages.|
|00003ee0| 20 41 0d 20 20 20 70 61 | 63 6b 61 67 65 20 69 73 | A. pa|ckage is|
|00003ef0| 20 61 20 66 69 6c 65 20 | 74 68 61 74 20 63 6f 6e | a file |that con|
|00003f00| 74 61 69 6e 73 20 73 6f | 6d 65 20 63 6f 6d 62 69 |tains so|me combi|
|00003f10| 6e 61 74 69 6f 6e 20 6f | 66 20 73 74 61 74 65 6d |nation o|f statem|
|00003f20| 65 6e 74 73 0d 20 20 20 | 61 6e 64 2f 6f 72 20 66 |ents. |and/or f|
|00003f30| 75 6e 63 74 69 6f 6e 73 | 20 74 68 61 74 20 70 65 |unctions| that pe|
|00003f40| 72 66 6f 72 6d 20 73 6f | 6d 65 20 73 70 65 63 69 |rform so|me speci|
|00003f50| 66 69 63 20 70 75 72 70 | 6f 73 65 2c 20 6f 72 20 |fic purp|ose, or |
|00003f60| 70 72 6f 76 69 64 65 73 | 20 61 0d 20 20 20 73 70 |provides| a. sp|
|00003f70| 65 63 69 66 69 63 20 66 | 75 6e 63 74 69 6f 6e 2e |ecific f|unction.|
|00003f80| 0d 0d 20 20 20 57 68 65 | 6e 20 77 72 69 74 69 6e |.. Whe|n writin|
|00003f90| 67 20 61 20 70 61 63 6b | 61 67 65 20 66 6f 72 20 |g a pack|age for |
|00003fa0| 67 65 6e 65 72 61 6c 20 | 75 73 65 2c 20 69 74 20 |general |use, it |
|00003fb0| 69 73 20 69 6d 70 6f 72 | 74 61 6e 74 20 74 68 61 |is impor|tant tha|
|00003fc0| 74 20 74 68 65 0d 20 20 | 20 65 6c 65 6d 65 6e 74 |t the. | element|
|00003fd0| 73 20 6f 66 20 74 68 65 | 20 70 61 63 6b 61 67 65 |s of the| package|
|00003fe0| 20 64 6f 20 6e 6f 74 20 | 61 64 76 65 72 73 65 6c | do not |adversel|
|00003ff0| 79 20 61 66 66 65 63 74 | 20 74 68 65 20 75 73 65 |y affect| the use|
|00004000| 72 27 73 0d 20 20 20 77 | 6f 72 6b 73 70 61 63 65 |r's. w|orkspace|
|00004010| 2e 20 54 68 65 20 75 73 | 65 72 27 73 20 77 6f 72 |. The us|er's wor|
|00004020| 6b 73 70 61 63 65 20 63 | 61 6e 20 62 65 20 61 76 |kspace c|an be av|
|00004030| 6f 69 64 65 64 20 74 68 | 72 6f 75 67 68 20 63 61 |oided th|rough ca|
|00004040| 72 65 66 75 6c 20 75 73 | 65 0d 20 20 20 6f 66 20 |reful us|e. of |
|00004050| 74 68 65 20 6c 6f 63 61 | 6c 2c 20 61 6e 64 20 73 |the loca|l, and s|
|00004060| 74 61 74 69 63 20 64 65 | 63 6c 61 72 61 74 69 6f |tatic de|claratio|
|00004070| 6e 73 2e 0d 0d 20 20 20 | 54 68 65 20 73 74 61 74 |ns... |The stat|
|00004080| 69 63 20 64 65 63 6c 61 | 72 61 74 69 6f 6e 20 72 |ic decla|ration r|
|00004090| 65 73 74 72 69 63 74 73 | 20 74 68 65 20 76 69 73 |estricts| the vis|
|000040a0| 69 62 69 6c 69 74 79 2c | 20 61 6e 64 20 61 63 63 |ibility,| and acc|
|000040b0| 65 73 73 69 62 69 6c 69 | 74 79 0d 20 20 20 6f 66 |essibili|ty. of|
|000040c0| 20 76 61 72 69 61 62 6c | 65 73 20 74 6f 20 74 68 | variabl|es to th|
|000040d0| 65 20 66 69 6c 65 20 74 | 68 61 74 20 74 68 65 20 |e file t|hat the |
|000040e0| 73 74 61 74 69 63 20 64 | 65 63 6c 61 72 61 74 69 |static d|eclarati|
|000040f0| 6f 6e 20 6f 63 63 75 72 | 73 20 77 69 74 68 69 6e |on occur|s within|
|00004100| 2e 0d 20 20 20 53 74 61 | 74 69 63 20 76 61 72 69 |.. Sta|tic vari|
|00004110| 61 62 6c 65 73 20 63 61 | 6e 6e 6f 74 20 62 65 20 |ables ca|nnot be |
|00004120| 61 6c 74 65 72 65 64 20 | 62 79 20 66 75 6e 63 74 |altered |by funct|
|00004130| 69 6f 6e 73 20 6f 72 20 | 73 74 61 74 65 6d 65 6e |ions or |statemen|
|00004140| 74 73 20 74 68 61 74 0d | 20 20 20 61 72 65 20 6e |ts that.| are n|
|00004150| 6f 74 20 77 69 74 68 69 | 6e 20 74 68 65 20 73 61 |ot withi|n the sa|
|00004160| 6d 65 20 66 69 6c 65 20 | 73 63 6f 70 65 2e 0d 0d |me file |scope...|
|00004170| 5c 62 65 67 69 6e 7b 66 | 69 67 75 72 65 7d 0d 5c |\begin{f|igure}.\|
|00004180| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0d |begin{ve|rbatim}.|
|00004190| 73 74 61 74 69 63 20 28 | 73 77 61 70 29 3b 0d 0d |static (|swap);..|
|000041a0| 6c 75 20 3d 20 66 75 6e | 63 74 69 6f 6e 20 28 20 |lu = fun|ction ( |
|000041b0| 41 20 29 0d 7b 0d 20 20 | 6c 6f 63 61 6c 20 28 69 |A ).{. |local (i|
|000041c0| 2c 20 6c 2c 20 75 2c 20 | 70 76 74 2c 20 78 29 0d |, l, u, |pvt, x).|
|000041d0| 0d 20 20 69 66 20 28 41 | 2e 6e 72 20 21 3d 20 41 |. if (A|.nr != A|
|000041e0| 2e 6e 63 29 20 7b 20 65 | 72 72 6f 72 20 28 22 6c |.nc) { e|rror ("l|
|000041f0| 75 28 29 20 72 65 71 75 | 69 72 65 73 20 73 71 75 |u() requ|ires squ|
|00004200| 61 72 65 20 41 22 29 3b | 20 7d 0d 0d 20 20 78 20 |are A");| }.. x |
|00004210| 3d 20 66 61 63 74 6f 72 | 20 28 41 29 3b 20 20 20 |= factor| (A); |
|00004220| 20 20 20 20 2f 2f 20 44 | 6f 20 74 68 65 20 66 61 | // D|o the fa|
|00004230| 63 74 6f 72 69 7a 61 74 | 69 6f 6e 0d 0d 20 20 2f |ctorizat|ion.. /|
|00004240| 2f 0d 20 20 2f 2f 20 4e | 6f 77 20 63 72 65 61 74 |/. // N|ow creat|
|00004250| 65 20 6c 2c 20 75 2c 20 | 61 6e 64 20 70 76 74 20 |e l, u, |and pvt |
|00004260| 66 72 6f 6d 20 6c 75 20 | 61 6e 64 20 70 76 74 2e |from lu |and pvt.|
|00004270| 0d 20 20 2f 2f 0d 0d 20 | 20 6c 20 3d 20 74 72 69 |. //.. | l = tri|
|00004280| 6c 20 28 78 2e 6c 75 2c | 20 2d 31 29 20 2b 20 65 |l (x.lu,| -1) + e|
|00004290| 79 65 20 28 73 69 7a 65 | 20 28 78 2e 6c 75 29 29 |ye (size| (x.lu))|
|000042a0| 3b 0d 20 20 75 20 3d 20 | 74 72 69 75 20 28 78 2e |;. u = |triu (x.|
|000042b0| 6c 75 29 3b 0d 20 20 70 | 76 74 20 3d 20 65 79 65 |lu);. p|vt = eye|
|000042c0| 20 28 73 69 7a 65 20 28 | 78 2e 6c 75 29 29 3b 0d | (size (|x.lu));.|
|000042d0| 0d 20 20 2f 2f 0d 20 20 | 2f 2f 20 4e 6f 77 20 72 |. //. |// Now r|
|000042e0| 65 2d 61 72 61 6e 67 65 | 20 74 68 65 20 63 6f 6c |e-arange| the col|
|000042f0| 75 6d 6e 73 20 6f 66 20 | 70 76 74 0d 20 20 2f 2f |umns of |pvt. //|
|00004300| 0d 0d 20 20 66 6f 72 20 | 28 69 20 69 6e 20 31 3a |.. for |(i in 1:|
|00004310| 6d 61 78 20 28 73 69 7a | 65 20 28 78 2e 6c 75 29 |max (siz|e (x.lu)|
|00004320| 29 29 0d 20 20 7b 0d 20 | 20 20 20 70 76 74 20 3d |)). {. | pvt =|
|00004330| 20 70 76 74 5b 20 3b 20 | 73 77 61 70 20 28 31 3a | pvt[ ; |swap (1:|
|00004340| 70 76 74 2e 6e 63 2c 20 | 69 2c 20 78 2e 70 76 74 |pvt.nc, |i, x.pvt|
|00004350| 5b 69 5d 29 20 5d 3b 0d | 20 20 7d 0d 20 20 72 65 |[i]) ];.| }. re|
|00004360| 74 75 72 6e 20 3c 3c 20 | 6c 20 3d 20 6c 3b 20 75 |turn << |l = l; u|
|00004370| 20 3d 20 75 3b 20 70 76 | 74 20 3d 20 70 76 74 20 | = u; pv|t = pvt |
|00004380| 3e 3e 3b 0d 7d 0d 0d 2f | 2f 0d 2f 2f 20 20 49 6e |>>;.}../|/.// In|
|00004390| 20 76 65 63 74 6f 72 20 | 56 2c 20 73 77 61 70 20 | vector |V, swap |
|000043a0| 65 6c 65 6d 65 6e 74 73 | 20 49 2c 20 4a 0d 2f 2f |elements| I, J.//|
|000043b0| 0d 73 77 61 70 20 3d 20 | 66 75 6e 63 74 69 6f 6e |.swap = |function|
|000043c0| 20 28 20 56 2c 20 49 2c | 20 4a 20 29 0d 7b 0d 20 | ( V, I,| J ).{. |
|000043d0| 20 6c 6f 63 61 6c 20 28 | 76 2c 20 74 6d 70 29 3b | local (|v, tmp);|
|000043e0| 0d 20 20 76 20 3d 20 56 | 3b 0d 20 20 74 6d 70 20 |. v = V|;. tmp |
|000043f0| 3d 20 76 5b 49 5d 3b 0d | 20 20 76 5b 49 5d 20 3d |= v[I];.| v[I] =|
|00004400| 20 76 5b 4a 5d 3b 0d 20 | 20 76 5b 4a 5d 20 3d 20 | v[J];. | v[J] = |
|00004410| 74 6d 70 3b 0d 20 20 72 | 65 74 75 72 6e 20 76 3b |tmp;. r|eturn v;|
|00004420| 0d 7d 3b 0d 5c 65 6e 64 | 7b 76 65 72 62 61 74 69 |.};.\end|{verbati|
|00004430| 6d 7d 0d 5c 63 61 70 74 | 69 6f 6e 7b 20 55 73 65 |m}.\capt|ion{ Use|
|00004440| 72 2d 46 75 6e 63 74 69 | 6f 6e 7d 20 5c 6c 61 62 |r-Functi|on} \lab|
|00004450| 65 6c 7b 66 69 67 3a 6c | 75 7d 0d 5c 65 6e 64 7b |el{fig:l|u}.\end{|
|00004460| 66 69 67 75 72 65 7d 0d | 0d 20 20 20 43 6f 6e 73 |figure}.|. Cons|
|00004470| 69 64 65 72 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |ider the| followi|
|00004480| 6e 67 20 65 78 61 6d 70 | 6c 65 3a 20 46 69 67 75 |ng examp|le: Figu|
|00004490| 72 65 7e 5c 72 65 66 7b | 66 69 67 3a 6c 75 7d 20 |re~\ref{|fig:lu} |
|000044a0| 63 6f 6e 74 61 69 6e 73 | 20 74 77 6f 0d 20 20 20 |contains| two. |
|000044b0| 66 75 6e 63 74 69 6f 6e | 73 2c 20 61 6e 64 20 61 |function|s, and a|
|000044c0| 20 73 74 61 74 69 63 20 | 64 65 63 6c 61 72 61 74 | static |declarat|
|000044d0| 69 6f 6e 2e 20 54 68 65 | 20 65 6e 74 69 72 65 20 |ion. The| entire |
|000044e0| 63 6f 6e 74 65 6e 74 73 | 20 6f 66 0d 20 20 20 46 |contents| of. F|
|000044f0| 69 67 75 72 65 7e 5c 72 | 65 66 7b 66 69 67 3a 6c |igure~\r|ef{fig:l|
|00004500| 75 7d 20 69 73 20 63 6f | 6e 74 61 69 6e 65 64 20 |u} is co|ntained |
|00004510| 77 69 74 68 69 6e 20 61 | 20 66 69 6c 65 20 6e 61 |within a| file na|
|00004520| 6d 65 64 20 5c 76 65 72 | 62 2b 6c 75 2e 72 2b 2e |med \ver|b+lu.r+.|
|00004530| 0d 20 20 20 53 69 6e 63 | 65 20 74 68 65 20 73 74 |. Sinc|e the st|
|00004540| 61 74 69 63 20 64 65 63 | 6c 61 72 61 74 69 6f 6e |atic dec|laration|
|00004550| 20 6f 63 63 75 72 73 20 | 77 69 74 68 69 6e 20 74 | occurs |within t|
|00004560| 68 65 20 66 69 6c 65 20 | 5c 76 65 72 62 2b 6c 75 |he file |\verb+lu|
|00004570| 2e 72 2b 2c 0d 20 20 20 | 6f 6e 6c 79 20 73 74 61 |.r+,. |only sta|
|00004580| 74 65 6d 65 6e 74 73 20 | 77 69 74 68 69 6e 20 74 |tements |within t|
|00004590| 68 61 74 20 66 69 6c 65 | 20 63 61 6e 20 75 73 65 |hat file| can use|
|000045a0| 20 74 68 65 20 73 74 61 | 74 69 63 61 6c 6c 79 20 | the sta|tically |
|000045b0| 64 65 63 6c 61 72 65 64 | 0d 20 20 20 76 61 72 69 |declared|. vari|
|000045c0| 61 62 6c 65 2c 20 77 68 | 69 63 68 2c 20 69 6e 20 |able, wh|ich, in |
|000045d0| 74 68 69 73 20 63 61 73 | 65 2c 20 69 73 20 74 68 |this cas|e, is th|
|000045e0| 65 20 76 61 72 69 61 62 | 6c 65 20 73 77 61 70 20 |e variab|le swap |
|000045f0| 28 61 20 75 73 65 72 0d | 20 20 20 66 75 6e 63 74 |(a user.| funct|
|00004600| 69 6f 6e 29 2e 20 5c 76 | 65 72 62 2b 73 77 61 70 |ion). \v|erb+swap|
|00004610| 2b 20 69 73 20 75 73 65 | 64 20 6c 69 6b 65 20 61 |+ is use|d like a|
|00004620| 6e 79 20 6f 74 68 65 72 | 20 76 61 72 69 61 62 6c |ny other| variabl|
|00004630| 65 2c 20 65 78 63 65 70 | 74 20 74 68 61 74 0d 20 |e, excep|t that. |
|00004640| 20 20 69 74 20 69 73 20 | 69 6e 76 69 73 69 62 6c | it is |invisibl|
|00004650| 65 20 74 6f 20 61 6e 79 | 20 73 74 61 74 65 6d 65 |e to any| stateme|
|00004660| 6e 74 20 6f 75 74 73 69 | 64 65 20 6f 66 20 74 68 |nt outsi|de of th|
|00004670| 65 20 66 69 6c 65 20 5c | 76 65 72 62 2b 6c 75 2e |e file \|verb+lu.|
|00004680| 72 2b 2e 20 0d 0d 5c 73 | 65 63 74 69 6f 6e 7b 43 |r+. ..\s|ection{C|
|00004690| 6f 6e 63 6c 75 73 69 6f | 6e 7d 0d 0d 20 20 20 54 |onclusio|n}.. T|
|000046a0| 68 69 73 20 63 6f 6e 63 | 6c 75 64 65 73 20 6f 75 |his conc|ludes ou|
|000046b0| 72 20 73 69 6d 70 6c 65 | 20 66 75 6e 63 74 69 6f |r simple| functio|
|000046c0| 6e 20 74 75 74 6f 72 69 | 61 6c 2e 20 57 65 20 68 |n tutori|al. We h|
|000046d0| 61 76 65 20 6a 75 73 74 | 20 62 61 72 65 6c 79 0d |ave just| barely.|
|000046e0| 20 20 20 63 6f 76 65 72 | 65 64 20 73 6f 6d 65 20 | cover|ed some |
|000046f0| 6f 66 20 74 68 65 20 63 | 61 70 61 62 69 6c 69 74 |of the c|apabilit|
|00004700| 69 65 73 20 6f 66 20 75 | 73 65 72 2d 66 75 6e 63 |ies of u|ser-func|
|00004710| 74 69 6f 6e 73 2e 20 54 | 6f 70 69 63 73 20 77 65 |tions. T|opics we|
|00004720| 20 68 61 76 65 0d 20 20 | 20 6e 6f 74 20 63 6f 76 | have. | not cov|
|00004730| 65 72 65 64 2c 20 74 68 | 61 74 20 79 6f 75 20 6d |ered, th|at you m|
|00004740| 61 79 20 77 69 73 68 20 | 74 6f 20 65 78 70 65 72 |ay wish |to exper|
|00004750| 69 6d 65 6e 74 20 77 69 | 74 68 20 61 72 65 3a 0d |iment wi|th are:.|
|00004760| 0d 20 20 20 5c 62 65 67 | 69 6e 7b 65 6e 75 6d 65 |. \beg|in{enume|
|00004770| 72 61 74 65 7d 0d 20 20 | 20 20 20 20 5c 69 74 65 |rate}. | \ite|
|00004780| 6d 20 50 61 73 73 69 6e | 67 20 66 75 6e 63 74 69 |m Passin|g functi|
|00004790| 6f 6e 73 20 61 73 20 61 | 72 67 75 6d 65 6e 74 73 |ons as a|rguments|
|000047a0| 20 74 6f 20 6f 74 68 65 | 72 20 66 75 6e 63 74 69 | to othe|r functi|
|000047b0| 6f 6e 73 2e 0d 20 20 20 | 20 20 20 5c 69 74 65 6d |ons.. | \item|
|000047c0| 20 55 73 69 6e 67 20 6c | 69 73 74 20 76 61 72 69 | Using l|ist vari|
|000047d0| 61 62 6c 65 73 20 74 6f | 20 67 65 74 20 74 68 65 |ables to| get the|
|000047e0| 20 65 66 66 65 63 74 20 | 6f 66 20 76 61 72 69 61 | effect |of varia|
|000047f0| 62 6c 65 20 6c 65 6e 67 | 74 68 0d 20 20 20 20 20 |ble leng|th. |
|00004800| 20 20 20 20 20 20 20 61 | 72 67 75 6d 65 6e 74 20 | a|rgument |
|00004810| 6c 69 73 74 73 2e 0d 20 | 20 20 20 20 20 5c 69 74 |lists.. | \it|
|00004820| 65 6d 20 55 73 69 6e 67 | 20 6c 69 73 74 20 76 61 |em Using| list va|
|00004830| 72 69 61 62 6c 65 73 2c | 20 61 6e 64 20 75 73 65 |riables,| and use|
|00004840| 72 2d 66 75 6e 63 74 69 | 6f 6e 73 20 74 6f 20 62 |r-functi|ons to b|
|00004850| 75 69 6c 64 20 79 6f 75 | 72 20 6f 77 6e 0d 20 20 |uild you|r own. |
|00004860| 20 20 20 20 20 20 20 20 | 20 20 60 60 6f 62 6a 65 | | ``obje|
|00004870| 63 74 73 27 27 2e 0d 20 | 20 20 5c 65 6e 64 7b 65 |cts''.. | \end{e|
|00004880| 6e 75 6d 65 72 61 74 65 | 7d 0d 0d 0d |numerate|}... |
+--------+-------------------------+-------------------------+--------+--------+